Skip to content

Commit 5346d3f

Browse files
committed
schema-codegen: force double quotes on enum strings. closes #161. (ref #139)
1 parent 372a898 commit 5346d3f

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@colyseus/schema",
3-
"version": "2.0.24",
3+
"version": "2.0.25",
44
"description": "Binary state serializer with delta encoding for games",
55
"bin": {
66
"schema-codegen": "./bin/schema-codegen"

src/codegen/languages/csharp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ${_enum.properties
8787
8888
if(prop.type) {
8989
if(isNaN(Number(prop.type))) {
90-
value = prop.type;
90+
value = `"${prop.type}"`;
9191
dataType = "string";
9292
} else {
9393
value = Number(prop.type);

src/codegen/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function inspectNode(node: ts.Node, context: Context, decoratorName: string) {
194194

195195
case ts.SyntaxKind.EnumMember:
196196
if (currentStructure instanceof Enum) {
197-
const initializer = (node as any).initializer?.getText();
197+
const initializer = (node as any).initializer?.text;
198198
const name = node.getFirstToken().getText();
199199
const property = currentProperty || new Property();
200200
property.name = name;

test/codegen/Codegen.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe("schema-codegen", () => {
5757
});
5858

5959
const outputFiles = glob.sync(path.resolve(OUTPUT_DIR, "*.cs"));
60-
console.log({ outputFiles });
6160
assert.strictEqual(2, outputFiles.length);
6261
});
6362

0 commit comments

Comments
 (0)