quicktype 16.0.43 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/CompressedJSONFromStream.js +26 -38
- package/dist/cli/GraphQLIntrospection.js +33 -41
- package/dist/cli/TypeSource.d.ts +1 -1
- package/dist/cli/URLGrammar.js +4 -3
- package/dist/cli/index.js +363 -364
- package/dist/quicktype-core/Annotation.js +2 -0
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
- package/dist/quicktype-core/ConvenienceRenderer.js +104 -81
- package/dist/quicktype-core/DateTime.js +1 -0
- package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
- package/dist/quicktype-core/DeclarationIR.js +13 -10
- package/dist/quicktype-core/EncodedMarkovChain.js +1 -0
- package/dist/quicktype-core/GatherNames.js +47 -25
- package/dist/quicktype-core/Graph.d.ts +2 -2
- package/dist/quicktype-core/Graph.js +23 -19
- package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
- package/dist/quicktype-core/GraphRewriting.js +65 -54
- package/dist/quicktype-core/MakeTransformations.js +23 -22
- package/dist/quicktype-core/MarkovChain.d.ts +3 -3
- package/dist/quicktype-core/MarkovChain.js +9 -8
- package/dist/quicktype-core/Messages.d.ts +3 -3
- package/dist/quicktype-core/Messages.js +8 -3
- package/dist/quicktype-core/Naming.d.ts +11 -11
- package/dist/quicktype-core/Naming.js +76 -61
- package/dist/quicktype-core/Renderer.d.ts +6 -6
- package/dist/quicktype-core/Renderer.js +34 -17
- package/dist/quicktype-core/RendererOptions.d.ts +5 -5
- package/dist/quicktype-core/RendererOptions.js +6 -3
- package/dist/quicktype-core/Run.d.ts +9 -9
- package/dist/quicktype-core/Run.js +72 -67
- package/dist/quicktype-core/Source.d.ts +3 -3
- package/dist/quicktype-core/Source.js +19 -18
- package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
- package/dist/quicktype-core/TargetLanguage.js +6 -2
- package/dist/quicktype-core/Transformers.d.ts +25 -25
- package/dist/quicktype-core/Transformers.js +94 -66
- package/dist/quicktype-core/Type.d.ts +41 -43
- package/dist/quicktype-core/Type.js +96 -71
- package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
- package/dist/quicktype-core/TypeBuilder.js +53 -47
- package/dist/quicktype-core/TypeGraph.d.ts +4 -4
- package/dist/quicktype-core/TypeGraph.js +49 -40
- package/dist/quicktype-core/TypeUtils.d.ts +2 -2
- package/dist/quicktype-core/TypeUtils.js +23 -22
- package/dist/quicktype-core/UnifyClasses.js +16 -12
- package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
- package/dist/quicktype-core/UnionBuilder.js +33 -30
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
- package/dist/quicktype-core/attributes/AccessorNames.js +18 -17
- package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
- package/dist/quicktype-core/attributes/Constraints.js +8 -4
- package/dist/quicktype-core/attributes/Description.js +6 -5
- package/dist/quicktype-core/attributes/EnumValues.js +4 -3
- package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
- package/dist/quicktype-core/attributes/StringTypes.js +24 -21
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
- package/dist/quicktype-core/attributes/TypeAttributes.js +12 -10
- package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
- package/dist/quicktype-core/attributes/TypeNames.js +49 -21
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
- package/dist/quicktype-core/attributes/URIAttributes.js +10 -6
- package/dist/quicktype-core/index.js +128 -125
- package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
- package/dist/quicktype-core/input/CompressedJSON.js +49 -54
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +5 -13
- package/dist/quicktype-core/input/Inference.d.ts +2 -2
- package/dist/quicktype-core/input/Inference.js +25 -17
- package/dist/quicktype-core/input/Inputs.d.ts +2 -2
- package/dist/quicktype-core/input/Inputs.js +38 -54
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
- package/dist/quicktype-core/input/JSONSchemaInput.js +503 -523
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
- package/dist/quicktype-core/input/JSONSchemaStore.js +24 -35
- package/dist/quicktype-core/input/PostmanCollection.js +2 -1
- package/dist/quicktype-core/input/io/NodeIO.js +55 -44
- package/dist/quicktype-core/input/io/get-stream/index.js +6 -2
- package/dist/quicktype-core/language/All.js +3 -2
- package/dist/quicktype-core/language/CPlusPlus.d.ts +8 -8
- package/dist/quicktype-core/language/CPlusPlus.js +185 -151
- package/dist/quicktype-core/language/CSharp.d.ts +7 -7
- package/dist/quicktype-core/language/CSharp.js +82 -72
- package/dist/quicktype-core/language/Crystal.d.ts +2 -2
- package/dist/quicktype-core/language/Crystal.js +18 -17
- package/dist/quicktype-core/language/Dart.d.ts +4 -4
- package/dist/quicktype-core/language/Dart.js +36 -34
- package/dist/quicktype-core/language/Elm.d.ts +6 -6
- package/dist/quicktype-core/language/Elm.js +47 -45
- package/dist/quicktype-core/language/Golang.d.ts +4 -4
- package/dist/quicktype-core/language/Golang.js +23 -20
- package/dist/quicktype-core/language/Haskell.d.ts +5 -5
- package/dist/quicktype-core/language/Haskell.js +25 -23
- package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
- package/dist/quicktype-core/language/JSONSchema.js +17 -16
- package/dist/quicktype-core/language/Java.d.ts +2 -2
- package/dist/quicktype-core/language/Java.js +97 -97
- package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
- package/dist/quicktype-core/language/JavaScript.js +19 -17
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +15 -13
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +12 -11
- package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
- package/dist/quicktype-core/language/Kotlin.js +39 -37
- package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
- package/dist/quicktype-core/language/Objective-C.js +45 -41
- package/dist/quicktype-core/language/Php.d.ts +2 -2
- package/dist/quicktype-core/language/Php.js +66 -41
- package/dist/quicktype-core/language/Pike.d.ts +1 -1
- package/dist/quicktype-core/language/Pike.js +18 -17
- package/dist/quicktype-core/language/Python.d.ts +8 -8
- package/dist/quicktype-core/language/Python.js +63 -64
- package/dist/quicktype-core/language/Rust.d.ts +2 -2
- package/dist/quicktype-core/language/Rust.js +21 -19
- package/dist/quicktype-core/language/Swift.d.ts +7 -7
- package/dist/quicktype-core/language/Swift.js +568 -565
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
- package/dist/quicktype-core/language/TypeScriptFlow.js +28 -26
- package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
- package/dist/quicktype-core/language/ruby/index.js +49 -24
- package/dist/quicktype-core/language/ruby/keywords.js +1 -0
- package/dist/quicktype-core/rewrites/CombineClasses.js +9 -8
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
- package/dist/quicktype-core/rewrites/ExpandStrings.js +18 -17
- package/dist/quicktype-core/rewrites/FlattenStrings.js +7 -6
- package/dist/quicktype-core/rewrites/FlattenUnions.js +9 -8
- package/dist/quicktype-core/rewrites/InferMaps.js +11 -10
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +8 -7
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +68 -67
- package/dist/quicktype-core/support/Acronyms.js +3 -1
- package/dist/quicktype-core/support/Chance.js +10 -0
- package/dist/quicktype-core/support/Converters.js +1 -0
- package/dist/quicktype-core/support/Strings.d.ts +4 -4
- package/dist/quicktype-core/support/Strings.js +17 -16
- package/dist/quicktype-core/support/Support.d.ts +1 -1
- package/dist/quicktype-core/support/Support.js +30 -6
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
- package/dist/quicktype-graphql-input/GraphQLSchema.js +1 -0
- package/dist/quicktype-graphql-input/index.d.ts +1 -1
- package/dist/quicktype-graphql-input/index.js +229 -212
- package/dist/quicktype-typescript-input/index.js +28 -4
- package/package.json +25 -19
|
@@ -11,8 +11,8 @@ export declare enum Framework {
|
|
|
11
11
|
Newtonsoft = 0,
|
|
12
12
|
SystemTextJson = 1
|
|
13
13
|
}
|
|
14
|
-
export
|
|
15
|
-
export
|
|
14
|
+
export type Version = 5 | 6;
|
|
15
|
+
export type OutputFeatures = {
|
|
16
16
|
helpers: boolean;
|
|
17
17
|
attributes: boolean;
|
|
18
18
|
};
|
|
@@ -21,7 +21,7 @@ export declare enum AccessModifier {
|
|
|
21
21
|
Public = 1,
|
|
22
22
|
Internal = 2
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type CSharpTypeForAny = "object" | "dynamic";
|
|
25
25
|
export declare const cSharpOptions: {
|
|
26
26
|
framework: EnumOption<Framework>;
|
|
27
27
|
useList: EnumOption<boolean>;
|
|
@@ -35,9 +35,9 @@ export declare const cSharpOptions: {
|
|
|
35
35
|
export declare class CSharpTargetLanguage extends TargetLanguage {
|
|
36
36
|
constructor();
|
|
37
37
|
protected getOptions(): Option<any>[];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
get stringTypeMapping(): StringTypeMapping;
|
|
39
|
+
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
40
|
+
get supportsOptionalClassProperties(): boolean;
|
|
41
41
|
needsTransformerForType(t: Type): boolean;
|
|
42
42
|
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
43
43
|
[name: string]: any;
|
|
@@ -56,7 +56,7 @@ export declare class CSharpRenderer extends ConvenienceRenderer {
|
|
|
56
56
|
protected unionNeedsName(u: UnionType): boolean;
|
|
57
57
|
protected namedTypeToNameForTopLevel(type: Type): Type | undefined;
|
|
58
58
|
protected emitBlock(f: () => void, semicolon?: boolean): void;
|
|
59
|
-
protected
|
|
59
|
+
protected get doubleType(): string;
|
|
60
60
|
protected csType(t: Type, follow?: (t: Type) => Type, withIssues?: boolean): Sourcelike;
|
|
61
61
|
protected nullableCSType(t: Type, follow?: (t: Type) => Type, withIssues?: boolean): Sourcelike;
|
|
62
62
|
protected baseclassForType(_t: Type): Sourcelike | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SystemTextJsonCSharpRenderer = exports.systemTextJsonCSharpOptions = exports.NewtonsoftCSharpRenderer = exports.newtonsoftCSharpOptions = exports.CSharpRenderer = exports.CSharpTargetLanguage = exports.cSharpOptions = exports.AccessModifier = exports.Framework = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const Type_1 = require("../Type");
|
|
5
6
|
const TypeUtils_1 = require("../TypeUtils");
|
|
@@ -30,7 +31,7 @@ function noFollow(t) {
|
|
|
30
31
|
}
|
|
31
32
|
function needTransformerForType(t) {
|
|
32
33
|
if (t instanceof Type_1.UnionType) {
|
|
33
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(t);
|
|
34
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(t);
|
|
34
35
|
if (maybeNullable === null)
|
|
35
36
|
return "automatic";
|
|
36
37
|
if (needTransformerForType(maybeNullable) === "manual")
|
|
@@ -46,11 +47,11 @@ function needTransformerForType(t) {
|
|
|
46
47
|
if (t instanceof Type_1.EnumType)
|
|
47
48
|
return "automatic";
|
|
48
49
|
if (t.kind === "double")
|
|
49
|
-
return Constraints_1.minMaxValueForType(t) !== undefined ? "manual" : "none";
|
|
50
|
+
return (0, Constraints_1.minMaxValueForType)(t) !== undefined ? "manual" : "none";
|
|
50
51
|
if (t.kind === "integer-string" || t.kind === "bool-string")
|
|
51
52
|
return "manual";
|
|
52
53
|
if (t.kind === "string") {
|
|
53
|
-
return Constraints_1.minMaxLengthForType(t) !== undefined ? "manual" : "none";
|
|
54
|
+
return (0, Constraints_1.minMaxLengthForType)(t) !== undefined ? "manual" : "none";
|
|
54
55
|
}
|
|
55
56
|
return "none";
|
|
56
57
|
}
|
|
@@ -59,7 +60,7 @@ function alwaysApplyTransformation(xf) {
|
|
|
59
60
|
if (t instanceof Type_1.EnumType)
|
|
60
61
|
return true;
|
|
61
62
|
if (t instanceof Type_1.UnionType)
|
|
62
|
-
return TypeUtils_1.nullableFromUnion(t) === null;
|
|
63
|
+
return (0, TypeUtils_1.nullableFromUnion)(t) === null;
|
|
63
64
|
return false;
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
@@ -74,7 +75,7 @@ function csTypeForTransformedStringType(t) {
|
|
|
74
75
|
case "uri":
|
|
75
76
|
return "Uri";
|
|
76
77
|
default:
|
|
77
|
-
return Support_1.panic(`Transformed string type ${t.kind} not supported`);
|
|
78
|
+
return (0, Support_1.panic)(`Transformed string type ${t.kind} not supported`);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
exports.cSharpOptions = {
|
|
@@ -144,19 +145,19 @@ class CSharpTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
144
145
|
return need !== "none" && need !== "nullable";
|
|
145
146
|
}
|
|
146
147
|
makeRenderer(renderContext, untypedOptionValues) {
|
|
147
|
-
const options = RendererOptions_1.getOptionValues(exports.cSharpOptions, untypedOptionValues);
|
|
148
|
+
const options = (0, RendererOptions_1.getOptionValues)(exports.cSharpOptions, untypedOptionValues);
|
|
148
149
|
switch (options.framework) {
|
|
149
150
|
case Framework.Newtonsoft:
|
|
150
|
-
return new NewtonsoftCSharpRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.newtonsoftCSharpOptions, untypedOptionValues));
|
|
151
|
+
return new NewtonsoftCSharpRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.newtonsoftCSharpOptions, untypedOptionValues));
|
|
151
152
|
case Framework.SystemTextJson:
|
|
152
|
-
return new SystemTextJsonCSharpRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.systemTextJsonCSharpOptions, untypedOptionValues));
|
|
153
|
+
return new SystemTextJsonCSharpRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.systemTextJsonCSharpOptions, untypedOptionValues));
|
|
153
154
|
default:
|
|
154
|
-
return Support_1.assertNever(options.framework);
|
|
155
|
+
return (0, Support_1.assertNever)(options.framework);
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
exports.CSharpTargetLanguage = CSharpTargetLanguage;
|
|
159
|
-
const namingFunction = Naming_1.funPrefixNamer("namer", csNameStyle);
|
|
160
|
+
const namingFunction = (0, Naming_1.funPrefixNamer)("namer", csNameStyle);
|
|
160
161
|
// FIXME: Make a Named?
|
|
161
162
|
const denseJsonPropertyName = "J";
|
|
162
163
|
const denseRequiredEnumName = "R";
|
|
@@ -174,18 +175,19 @@ function isPartCharacter(utf16Unit) {
|
|
|
174
175
|
}
|
|
175
176
|
return isStartCharacter(utf16Unit);
|
|
176
177
|
}
|
|
177
|
-
const legalizeName = Strings_1.utf16LegalizeCharacters(isPartCharacter);
|
|
178
|
+
const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
|
|
178
179
|
function csNameStyle(original) {
|
|
179
|
-
const words = Strings_1.splitIntoWords(original);
|
|
180
|
-
return Strings_1.combineWords(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, "", isStartCharacter);
|
|
180
|
+
const words = (0, Strings_1.splitIntoWords)(original);
|
|
181
|
+
return (0, Strings_1.combineWords)(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, "", isStartCharacter);
|
|
181
182
|
}
|
|
182
183
|
function isValueType(t) {
|
|
183
184
|
if (t instanceof Type_1.UnionType) {
|
|
184
|
-
return TypeUtils_1.nullableFromUnion(t) === null;
|
|
185
|
+
return (0, TypeUtils_1.nullableFromUnion)(t) === null;
|
|
185
186
|
}
|
|
186
187
|
return ["integer", "double", "bool", "enum", "date-time", "uuid"].indexOf(t.kind) >= 0;
|
|
187
188
|
}
|
|
188
189
|
class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
190
|
+
_csOptions;
|
|
189
191
|
constructor(targetLanguage, renderContext, _csOptions) {
|
|
190
192
|
super(targetLanguage, renderContext);
|
|
191
193
|
this._csOptions = _csOptions;
|
|
@@ -224,13 +226,13 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
224
226
|
return namingFunction;
|
|
225
227
|
}
|
|
226
228
|
unionNeedsName(u) {
|
|
227
|
-
return TypeUtils_1.nullableFromUnion(u) === null;
|
|
229
|
+
return (0, TypeUtils_1.nullableFromUnion)(u) === null;
|
|
228
230
|
}
|
|
229
231
|
namedTypeToNameForTopLevel(type) {
|
|
230
232
|
// If the top-level type doesn't contain any classes or unions
|
|
231
233
|
// we have to define a class just for the `FromJson` method, in
|
|
232
234
|
// emitFromJsonForTopLevel.
|
|
233
|
-
return TypeUtils_1.directlyReachableSingleNamedType(type);
|
|
235
|
+
return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
|
|
234
236
|
}
|
|
235
237
|
emitBlock(f, semicolon = false) {
|
|
236
238
|
this.emitLine("{");
|
|
@@ -242,7 +244,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
242
244
|
}
|
|
243
245
|
csType(t, follow = Transformers_1.followTargetType, withIssues = false) {
|
|
244
246
|
const actualType = follow(t);
|
|
245
|
-
return TypeUtils_1.matchType(actualType, _anyType => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, this._csOptions.typeForAny), _nullType => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, this._csOptions.typeForAny), _boolType => "bool", _integerType => "long", _doubleType => this.doubleType, _stringType => "string", arrayType => {
|
|
247
|
+
return (0, TypeUtils_1.matchType)(actualType, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, this._csOptions.typeForAny), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, this._csOptions.typeForAny), _boolType => "bool", _integerType => "long", _doubleType => this.doubleType, _stringType => "string", arrayType => {
|
|
246
248
|
const itemsType = this.csType(arrayType.items, follow, withIssues);
|
|
247
249
|
if (this._csOptions.useList) {
|
|
248
250
|
return ["System.Collections.Generic.List<", itemsType, ">"];
|
|
@@ -255,14 +257,14 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
255
257
|
this.csType(mapType.values, follow, withIssues),
|
|
256
258
|
">"
|
|
257
259
|
], enumType => this.nameForNamedType(enumType), unionType => {
|
|
258
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
260
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
259
261
|
if (nullable !== null)
|
|
260
262
|
return this.nullableCSType(nullable, noFollow);
|
|
261
263
|
return this.nameForNamedType(unionType);
|
|
262
264
|
}, transformedStringType => csTypeForTransformedStringType(transformedStringType));
|
|
263
265
|
}
|
|
264
266
|
nullableCSType(t, follow = Transformers_1.followTargetType, withIssues = false) {
|
|
265
|
-
t = Transformers_1.followTargetType(t);
|
|
267
|
+
t = (0, Transformers_1.followTargetType)(t);
|
|
266
268
|
const csType = this.csType(t, follow, withIssues);
|
|
267
269
|
if (isValueType(t)) {
|
|
268
270
|
return [csType, "?"];
|
|
@@ -362,7 +364,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
362
364
|
});
|
|
363
365
|
}
|
|
364
366
|
emitUnionDefinition(u, unionName) {
|
|
365
|
-
const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
|
|
367
|
+
const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
|
|
366
368
|
this.emitType(this.descriptionForType(u), AccessModifier.Public, "partial struct", unionName, this.baseclassForType(u), () => {
|
|
367
369
|
this.forEachUnionMember(u, nonNulls, "none", null, (fieldName, t) => {
|
|
368
370
|
const csType = this.nullableCSType(t);
|
|
@@ -380,7 +382,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
380
382
|
});
|
|
381
383
|
if (u.findMember("null") === undefined)
|
|
382
384
|
return;
|
|
383
|
-
this.emitExpressionMember("public bool IsNull", collection_utils_1.arrayIntercalate(" && ", nullTests), true);
|
|
385
|
+
this.emitExpressionMember("public bool IsNull", (0, collection_utils_1.arrayIntercalate)(" && ", nullTests), true);
|
|
384
386
|
});
|
|
385
387
|
}
|
|
386
388
|
emitEnumDefinition(e, enumName) {
|
|
@@ -412,7 +414,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
416
|
emitTypeSwitch(types, condition, withBlock, withReturn, f) {
|
|
415
|
-
Support_1.assert(!withReturn || withBlock, "Can only have return with block");
|
|
417
|
+
(0, Support_1.assert)(!withReturn || withBlock, "Can only have return with block");
|
|
416
418
|
for (const t of types) {
|
|
417
419
|
this.emitLine("if (", condition(t), ")");
|
|
418
420
|
if (withBlock) {
|
|
@@ -491,10 +493,14 @@ exports.newtonsoftCSharpOptions = Object.assign({}, exports.cSharpOptions, {
|
|
|
491
493
|
checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false)
|
|
492
494
|
});
|
|
493
495
|
class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
496
|
+
_options;
|
|
497
|
+
_enumExtensionsNames = new Map();
|
|
498
|
+
_needHelpers;
|
|
499
|
+
_needAttributes;
|
|
500
|
+
_needNamespaces;
|
|
494
501
|
constructor(targetLanguage, renderContext, _options) {
|
|
495
502
|
super(targetLanguage, renderContext, _options);
|
|
496
503
|
this._options = _options;
|
|
497
|
-
this._enumExtensionsNames = new Map();
|
|
498
504
|
this._needHelpers = _options.features.helpers;
|
|
499
505
|
this._needAttributes = _options.features.attributes;
|
|
500
506
|
this._needNamespaces = _options.features.namespaces;
|
|
@@ -581,31 +587,31 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
581
587
|
else {
|
|
582
588
|
rhs = [topLevelName, ".FromJson(jsonString)"];
|
|
583
589
|
}
|
|
584
|
-
this.emitLine("// var ", Source_1.modifySource(Strings_1.camelCase, topLevelName), " = ", rhs, ";");
|
|
590
|
+
this.emitLine("// var ", (0, Source_1.modifySource)(Strings_1.camelCase, topLevelName), " = ", rhs, ";");
|
|
585
591
|
});
|
|
586
592
|
}
|
|
587
593
|
converterForType(t) {
|
|
588
|
-
let xf = Transformers_1.transformationForType(t);
|
|
594
|
+
let xf = (0, Transformers_1.transformationForType)(t);
|
|
589
595
|
if (xf === undefined && t instanceof Type_1.UnionType) {
|
|
590
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(t);
|
|
596
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(t);
|
|
591
597
|
if (maybeNullable !== null) {
|
|
592
598
|
t = maybeNullable;
|
|
593
|
-
xf = Transformers_1.transformationForType(t);
|
|
599
|
+
xf = (0, Transformers_1.transformationForType)(t);
|
|
594
600
|
}
|
|
595
601
|
}
|
|
596
602
|
if (xf === undefined)
|
|
597
603
|
return undefined;
|
|
598
604
|
if (alwaysApplyTransformation(xf))
|
|
599
605
|
return undefined;
|
|
600
|
-
return Support_1.defined(this.nameForTransformation(t));
|
|
606
|
+
return (0, Support_1.defined)(this.nameForTransformation(t));
|
|
601
607
|
}
|
|
602
608
|
attributesForProperty(property, _name, _c, jsonName) {
|
|
603
609
|
if (!this._needAttributes)
|
|
604
610
|
return undefined;
|
|
605
611
|
const attributes = [];
|
|
606
612
|
const jsonProperty = this._options.dense ? denseJsonPropertyName : "JsonProperty";
|
|
607
|
-
const escapedName = Strings_1.utf16StringEscape(jsonName);
|
|
608
|
-
const isNullable = Transformers_1.followTargetType(property.type).isNullable;
|
|
613
|
+
const escapedName = (0, Strings_1.utf16StringEscape)(jsonName);
|
|
614
|
+
const isNullable = (0, Transformers_1.followTargetType)(property.type).isNullable;
|
|
609
615
|
const isOptional = property.isOptional;
|
|
610
616
|
const requiredClass = this._options.dense ? "R" : "Required";
|
|
611
617
|
const nullValueHandlingClass = this._options.dense ? "N" : "NullValueHandling";
|
|
@@ -715,7 +721,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
715
721
|
this.emitLine("{");
|
|
716
722
|
this.indent(() => {
|
|
717
723
|
for (const [t, converter] of this.typesWithNamedTransformations) {
|
|
718
|
-
if (alwaysApplyTransformation(Support_1.defined(Transformers_1.transformationForType(t)))) {
|
|
724
|
+
if (alwaysApplyTransformation((0, Support_1.defined)((0, Transformers_1.transformationForType)(t)))) {
|
|
719
725
|
this.emitLine(this.converterObject(converter), ",");
|
|
720
726
|
}
|
|
721
727
|
}
|
|
@@ -765,7 +771,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
765
771
|
else if (xfer instanceof Transformers_1.ArrayDecodingTransformer) {
|
|
766
772
|
// FIXME: Consume StartArray
|
|
767
773
|
if (!(targetType instanceof Type_1.ArrayType)) {
|
|
768
|
-
return Support_1.panic("Array decoding must produce an array type");
|
|
774
|
+
return (0, Support_1.panic)("Array decoding must produce an array type");
|
|
769
775
|
}
|
|
770
776
|
// FIXME: handle EOF
|
|
771
777
|
this.emitLine("reader.Read();");
|
|
@@ -805,24 +811,24 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
805
811
|
return false;
|
|
806
812
|
}
|
|
807
813
|
else {
|
|
808
|
-
return Support_1.panic("Unknown transformer");
|
|
814
|
+
return (0, Support_1.panic)("Unknown transformer");
|
|
809
815
|
}
|
|
810
816
|
}
|
|
811
817
|
stringCaseValue(t, stringCase) {
|
|
812
818
|
if (t.kind === "string") {
|
|
813
|
-
return ['"', Strings_1.utf16StringEscape(stringCase), '"'];
|
|
819
|
+
return ['"', (0, Strings_1.utf16StringEscape)(stringCase), '"'];
|
|
814
820
|
}
|
|
815
821
|
else if (t instanceof Type_1.EnumType) {
|
|
816
822
|
return [this.nameForNamedType(t), ".", this.nameForEnumCase(t, stringCase)];
|
|
817
823
|
}
|
|
818
|
-
return Support_1.panic(`Type ${t.kind} does not have string cases`);
|
|
824
|
+
return (0, Support_1.panic)(`Type ${t.kind} does not have string cases`);
|
|
819
825
|
}
|
|
820
826
|
emitTransformer(variable, xfer, targetType, emitFinish) {
|
|
821
827
|
function directTargetType(continuation) {
|
|
822
828
|
if (continuation === undefined) {
|
|
823
829
|
return targetType;
|
|
824
830
|
}
|
|
825
|
-
return Transformers_1.followTargetType(continuation.sourceType);
|
|
831
|
+
return (0, Transformers_1.followTargetType)(continuation.sourceType);
|
|
826
832
|
}
|
|
827
833
|
if (xfer instanceof Transformers_1.ChoiceTransformer) {
|
|
828
834
|
const caseXfers = xfer.transformers;
|
|
@@ -831,7 +837,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
831
837
|
this.emitBlock(() => {
|
|
832
838
|
for (const caseXfer of caseXfers) {
|
|
833
839
|
const matchXfer = caseXfer;
|
|
834
|
-
const value = this.stringCaseValue(Transformers_1.followTargetType(matchXfer.sourceType), matchXfer.stringCase);
|
|
840
|
+
const value = this.stringCaseValue((0, Transformers_1.followTargetType)(matchXfer.sourceType), matchXfer.stringCase);
|
|
835
841
|
this.emitLine("case ", value, ":");
|
|
836
842
|
this.indent(() => {
|
|
837
843
|
const allDone = this.emitTransformer(variable, matchXfer.transformer, targetType, emitFinish);
|
|
@@ -852,7 +858,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
852
858
|
}
|
|
853
859
|
else if (xfer instanceof Transformers_1.UnionMemberMatchTransformer) {
|
|
854
860
|
const memberType = xfer.memberType;
|
|
855
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(xfer.sourceType);
|
|
861
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(xfer.sourceType);
|
|
856
862
|
let test;
|
|
857
863
|
let member;
|
|
858
864
|
if (maybeNullable !== null) {
|
|
@@ -881,7 +887,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
881
887
|
this.emitBlock(() => this.emitTransformer(member, xfer.transformer, targetType, emitFinish));
|
|
882
888
|
}
|
|
883
889
|
else if (xfer instanceof Transformers_1.StringMatchTransformer) {
|
|
884
|
-
const value = this.stringCaseValue(Transformers_1.followTargetType(xfer.sourceType), xfer.stringCase);
|
|
890
|
+
const value = this.stringCaseValue((0, Transformers_1.followTargetType)(xfer.sourceType), xfer.stringCase);
|
|
885
891
|
this.emitLine("if (", variable, " == ", value, ")");
|
|
886
892
|
this.emitBlock(() => this.emitTransformer(variable, xfer.transformer, targetType, emitFinish));
|
|
887
893
|
}
|
|
@@ -942,7 +948,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
942
948
|
this.emitBlock(() => this.emitConsume("b", xfer.consumer, targetType, emitFinish));
|
|
943
949
|
break;
|
|
944
950
|
default:
|
|
945
|
-
return Support_1.panic(`Parsing string to ${immediateTargetType.kind} not supported`);
|
|
951
|
+
return (0, Support_1.panic)(`Parsing string to ${immediateTargetType.kind} not supported`);
|
|
946
952
|
}
|
|
947
953
|
}
|
|
948
954
|
else if (xfer instanceof Transformers_1.StringifyTransformer) {
|
|
@@ -958,7 +964,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
958
964
|
this.emitLine("var boolString = ", variable, ' ? "true" : "false";');
|
|
959
965
|
return this.emitConsume("boolString", xfer.consumer, targetType, emitFinish);
|
|
960
966
|
default:
|
|
961
|
-
return Support_1.panic(`Stringifying ${xfer.sourceType.kind} not supported`);
|
|
967
|
+
return (0, Support_1.panic)(`Stringifying ${xfer.sourceType.kind} not supported`);
|
|
962
968
|
}
|
|
963
969
|
}
|
|
964
970
|
else if (xfer instanceof Transformers_1.StringProducerTransformer) {
|
|
@@ -975,7 +981,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
975
981
|
if (max !== undefined) {
|
|
976
982
|
conditions.push([variable, ".Length <= ", max.toString()]);
|
|
977
983
|
}
|
|
978
|
-
this.emitLine("if (", collection_utils_1.arrayIntercalate([" && "], conditions), ")");
|
|
984
|
+
this.emitLine("if (", (0, collection_utils_1.arrayIntercalate)([" && "], conditions), ")");
|
|
979
985
|
this.emitBlock(() => this.emitConsume(variable, xfer.consumer, targetType, emitFinish));
|
|
980
986
|
return false;
|
|
981
987
|
}
|
|
@@ -989,15 +995,15 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
989
995
|
if (max !== undefined) {
|
|
990
996
|
conditions.push([variable, " <= ", max.toString()]);
|
|
991
997
|
}
|
|
992
|
-
this.emitLine("if (", collection_utils_1.arrayIntercalate([" && "], conditions), ")");
|
|
998
|
+
this.emitLine("if (", (0, collection_utils_1.arrayIntercalate)([" && "], conditions), ")");
|
|
993
999
|
this.emitBlock(() => this.emitConsume(variable, xfer.consumer, targetType, emitFinish));
|
|
994
1000
|
return false;
|
|
995
1001
|
}
|
|
996
1002
|
else if (xfer instanceof Transformers_1.UnionInstantiationTransformer) {
|
|
997
1003
|
if (!(targetType instanceof Type_1.UnionType)) {
|
|
998
|
-
return Support_1.panic("Union instantiation transformer must produce a union type");
|
|
1004
|
+
return (0, Support_1.panic)("Union instantiation transformer must produce a union type");
|
|
999
1005
|
}
|
|
1000
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(targetType);
|
|
1006
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(targetType);
|
|
1001
1007
|
if (maybeNullable !== null) {
|
|
1002
1008
|
emitFinish(variable);
|
|
1003
1009
|
}
|
|
@@ -1016,12 +1022,12 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
|
|
|
1016
1022
|
return true;
|
|
1017
1023
|
}
|
|
1018
1024
|
else {
|
|
1019
|
-
return Support_1.panic("Unknown transformer");
|
|
1025
|
+
return (0, Support_1.panic)("Unknown transformer");
|
|
1020
1026
|
}
|
|
1021
1027
|
return false;
|
|
1022
1028
|
}
|
|
1023
1029
|
emitTransformation(converterName, t) {
|
|
1024
|
-
const xf = Support_1.defined(Transformers_1.transformationForType(t));
|
|
1030
|
+
const xf = (0, Support_1.defined)((0, Transformers_1.transformationForType)(t));
|
|
1025
1031
|
const reverse = xf.reverse;
|
|
1026
1032
|
const targetType = xf.targetType;
|
|
1027
1033
|
const xfer = xf.transformer;
|
|
@@ -1100,10 +1106,14 @@ exports.systemTextJsonCSharpOptions = Object.assign({}, exports.cSharpOptions, {
|
|
|
1100
1106
|
checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false)
|
|
1101
1107
|
});
|
|
1102
1108
|
class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
1109
|
+
_options;
|
|
1110
|
+
_enumExtensionsNames = new Map();
|
|
1111
|
+
_needHelpers;
|
|
1112
|
+
_needAttributes;
|
|
1113
|
+
_needNamespaces;
|
|
1103
1114
|
constructor(targetLanguage, renderContext, _options) {
|
|
1104
1115
|
super(targetLanguage, renderContext, _options);
|
|
1105
1116
|
this._options = _options;
|
|
1106
|
-
this._enumExtensionsNames = new Map();
|
|
1107
1117
|
this._needHelpers = _options.features.helpers;
|
|
1108
1118
|
this._needAttributes = _options.features.attributes;
|
|
1109
1119
|
this._needNamespaces = _options.features.namespaces;
|
|
@@ -1198,7 +1208,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1198
1208
|
else {
|
|
1199
1209
|
rhs = [topLevelName, ".FromJson(jsonString)"];
|
|
1200
1210
|
}
|
|
1201
|
-
this.emitLine("// var ", Source_1.modifySource(Strings_1.camelCase, topLevelName), " = ", rhs, ";");
|
|
1211
|
+
this.emitLine("// var ", (0, Source_1.modifySource)(Strings_1.camelCase, topLevelName), " = ", rhs, ";");
|
|
1202
1212
|
});
|
|
1203
1213
|
// fix: should this be an option? Or respond to an existing option?
|
|
1204
1214
|
this.emitLine("#nullable enable");
|
|
@@ -1207,27 +1217,27 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1207
1217
|
this.emitLine("#pragma warning disable CS8603");
|
|
1208
1218
|
}
|
|
1209
1219
|
converterForType(t) {
|
|
1210
|
-
let xf = Transformers_1.transformationForType(t);
|
|
1220
|
+
let xf = (0, Transformers_1.transformationForType)(t);
|
|
1211
1221
|
if (xf === undefined && t instanceof Type_1.UnionType) {
|
|
1212
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(t);
|
|
1222
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(t);
|
|
1213
1223
|
if (maybeNullable !== null) {
|
|
1214
1224
|
t = maybeNullable;
|
|
1215
|
-
xf = Transformers_1.transformationForType(t);
|
|
1225
|
+
xf = (0, Transformers_1.transformationForType)(t);
|
|
1216
1226
|
}
|
|
1217
1227
|
}
|
|
1218
1228
|
if (xf === undefined)
|
|
1219
1229
|
return undefined;
|
|
1220
1230
|
if (alwaysApplyTransformation(xf))
|
|
1221
1231
|
return undefined;
|
|
1222
|
-
return Support_1.defined(this.nameForTransformation(t));
|
|
1232
|
+
return (0, Support_1.defined)(this.nameForTransformation(t));
|
|
1223
1233
|
}
|
|
1224
1234
|
attributesForProperty(property, _name, _c, jsonName) {
|
|
1225
1235
|
if (!this._needAttributes)
|
|
1226
1236
|
return undefined;
|
|
1227
1237
|
const attributes = [];
|
|
1228
1238
|
const jsonPropertyName = this._options.dense ? denseJsonPropertyName : "JsonPropertyName";
|
|
1229
|
-
const escapedName = Strings_1.utf16StringEscape(jsonName);
|
|
1230
|
-
const isNullable = Transformers_1.followTargetType(property.type).isNullable;
|
|
1239
|
+
const escapedName = (0, Strings_1.utf16StringEscape)(jsonName);
|
|
1240
|
+
const isNullable = (0, Transformers_1.followTargetType)(property.type).isNullable;
|
|
1231
1241
|
const isOptional = property.isOptional;
|
|
1232
1242
|
if (isOptional && !isNullable) {
|
|
1233
1243
|
attributes.push(["[", "JsonIgnore", "(Condition = JsonIgnoreCondition.WhenWritingNull)]"]);
|
|
@@ -1354,7 +1364,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1354
1364
|
this.emitLine("{");
|
|
1355
1365
|
this.indent(() => {
|
|
1356
1366
|
for (const [t, converter] of this.typesWithNamedTransformations) {
|
|
1357
|
-
if (alwaysApplyTransformation(Support_1.defined(Transformers_1.transformationForType(t)))) {
|
|
1367
|
+
if (alwaysApplyTransformation((0, Support_1.defined)((0, Transformers_1.transformationForType)(t)))) {
|
|
1358
1368
|
this.emitLine(this.converterObject(converter), ",");
|
|
1359
1369
|
}
|
|
1360
1370
|
}
|
|
@@ -1407,7 +1417,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1407
1417
|
else if (xfer instanceof Transformers_1.ArrayDecodingTransformer) {
|
|
1408
1418
|
// FIXME: Consume StartArray
|
|
1409
1419
|
if (!(targetType instanceof Type_1.ArrayType)) {
|
|
1410
|
-
return Support_1.panic("Array decoding must produce an array type");
|
|
1420
|
+
return (0, Support_1.panic)("Array decoding must produce an array type");
|
|
1411
1421
|
}
|
|
1412
1422
|
// FIXME: handle EOF
|
|
1413
1423
|
this.emitLine("reader.Read();");
|
|
@@ -1451,24 +1461,24 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1451
1461
|
return false;
|
|
1452
1462
|
}
|
|
1453
1463
|
else {
|
|
1454
|
-
return Support_1.panic("Unknown transformer");
|
|
1464
|
+
return (0, Support_1.panic)("Unknown transformer");
|
|
1455
1465
|
}
|
|
1456
1466
|
}
|
|
1457
1467
|
stringCaseValue(t, stringCase) {
|
|
1458
1468
|
if (t.kind === "string") {
|
|
1459
|
-
return ['"', Strings_1.utf16StringEscape(stringCase), '"'];
|
|
1469
|
+
return ['"', (0, Strings_1.utf16StringEscape)(stringCase), '"'];
|
|
1460
1470
|
}
|
|
1461
1471
|
else if (t instanceof Type_1.EnumType) {
|
|
1462
1472
|
return [this.nameForNamedType(t), ".", this.nameForEnumCase(t, stringCase)];
|
|
1463
1473
|
}
|
|
1464
|
-
return Support_1.panic(`Type ${t.kind} does not have string cases`);
|
|
1474
|
+
return (0, Support_1.panic)(`Type ${t.kind} does not have string cases`);
|
|
1465
1475
|
}
|
|
1466
1476
|
emitTransformer(variable, xfer, targetType, emitFinish) {
|
|
1467
1477
|
function directTargetType(continuation) {
|
|
1468
1478
|
if (continuation === undefined) {
|
|
1469
1479
|
return targetType;
|
|
1470
1480
|
}
|
|
1471
|
-
return Transformers_1.followTargetType(continuation.sourceType);
|
|
1481
|
+
return (0, Transformers_1.followTargetType)(continuation.sourceType);
|
|
1472
1482
|
}
|
|
1473
1483
|
if (xfer instanceof Transformers_1.ChoiceTransformer) {
|
|
1474
1484
|
const caseXfers = xfer.transformers;
|
|
@@ -1477,7 +1487,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1477
1487
|
this.emitBlock(() => {
|
|
1478
1488
|
for (const caseXfer of caseXfers) {
|
|
1479
1489
|
const matchXfer = caseXfer;
|
|
1480
|
-
const value = this.stringCaseValue(Transformers_1.followTargetType(matchXfer.sourceType), matchXfer.stringCase);
|
|
1490
|
+
const value = this.stringCaseValue((0, Transformers_1.followTargetType)(matchXfer.sourceType), matchXfer.stringCase);
|
|
1481
1491
|
this.emitLine("case ", value, ":");
|
|
1482
1492
|
this.indent(() => {
|
|
1483
1493
|
const allDone = this.emitTransformer(variable, matchXfer.transformer, targetType, emitFinish);
|
|
@@ -1498,7 +1508,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1498
1508
|
}
|
|
1499
1509
|
else if (xfer instanceof Transformers_1.UnionMemberMatchTransformer) {
|
|
1500
1510
|
const memberType = xfer.memberType;
|
|
1501
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(xfer.sourceType);
|
|
1511
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(xfer.sourceType);
|
|
1502
1512
|
let test;
|
|
1503
1513
|
let member;
|
|
1504
1514
|
if (maybeNullable !== null) {
|
|
@@ -1527,7 +1537,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1527
1537
|
this.emitBlock(() => this.emitTransformer(member, xfer.transformer, targetType, emitFinish));
|
|
1528
1538
|
}
|
|
1529
1539
|
else if (xfer instanceof Transformers_1.StringMatchTransformer) {
|
|
1530
|
-
const value = this.stringCaseValue(Transformers_1.followTargetType(xfer.sourceType), xfer.stringCase);
|
|
1540
|
+
const value = this.stringCaseValue((0, Transformers_1.followTargetType)(xfer.sourceType), xfer.stringCase);
|
|
1531
1541
|
this.emitLine("if (", variable, " == ", value, ")");
|
|
1532
1542
|
this.emitBlock(() => this.emitTransformer(variable, xfer.transformer, targetType, emitFinish));
|
|
1533
1543
|
}
|
|
@@ -1594,7 +1604,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1594
1604
|
this.emitBlock(() => this.emitConsume("b", xfer.consumer, targetType, emitFinish));
|
|
1595
1605
|
break;
|
|
1596
1606
|
default:
|
|
1597
|
-
return Support_1.panic(`Parsing string to ${immediateTargetType.kind} not supported`);
|
|
1607
|
+
return (0, Support_1.panic)(`Parsing string to ${immediateTargetType.kind} not supported`);
|
|
1598
1608
|
}
|
|
1599
1609
|
}
|
|
1600
1610
|
else if (xfer instanceof Transformers_1.StringifyTransformer) {
|
|
@@ -1610,7 +1620,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1610
1620
|
this.emitLine("var boolString = ", variable, ' ? "true" : "false";');
|
|
1611
1621
|
return this.emitConsume("boolString", xfer.consumer, targetType, emitFinish);
|
|
1612
1622
|
default:
|
|
1613
|
-
return Support_1.panic(`Stringifying ${xfer.sourceType.kind} not supported`);
|
|
1623
|
+
return (0, Support_1.panic)(`Stringifying ${xfer.sourceType.kind} not supported`);
|
|
1614
1624
|
}
|
|
1615
1625
|
}
|
|
1616
1626
|
else if (xfer instanceof Transformers_1.StringProducerTransformer) {
|
|
@@ -1627,7 +1637,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1627
1637
|
if (max !== undefined) {
|
|
1628
1638
|
conditions.push([variable, ".Length <= ", max.toString()]);
|
|
1629
1639
|
}
|
|
1630
|
-
this.emitLine("if (", collection_utils_1.arrayIntercalate([" && "], conditions), ")");
|
|
1640
|
+
this.emitLine("if (", (0, collection_utils_1.arrayIntercalate)([" && "], conditions), ")");
|
|
1631
1641
|
this.emitBlock(() => this.emitConsume(variable, xfer.consumer, targetType, emitFinish));
|
|
1632
1642
|
return false;
|
|
1633
1643
|
}
|
|
@@ -1641,15 +1651,15 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1641
1651
|
if (max !== undefined) {
|
|
1642
1652
|
conditions.push([variable, " <= ", max.toString()]);
|
|
1643
1653
|
}
|
|
1644
|
-
this.emitLine("if (", collection_utils_1.arrayIntercalate([" && "], conditions), ")");
|
|
1654
|
+
this.emitLine("if (", (0, collection_utils_1.arrayIntercalate)([" && "], conditions), ")");
|
|
1645
1655
|
this.emitBlock(() => this.emitConsume(variable, xfer.consumer, targetType, emitFinish));
|
|
1646
1656
|
return false;
|
|
1647
1657
|
}
|
|
1648
1658
|
else if (xfer instanceof Transformers_1.UnionInstantiationTransformer) {
|
|
1649
1659
|
if (!(targetType instanceof Type_1.UnionType)) {
|
|
1650
|
-
return Support_1.panic("Union instantiation transformer must produce a union type");
|
|
1660
|
+
return (0, Support_1.panic)("Union instantiation transformer must produce a union type");
|
|
1651
1661
|
}
|
|
1652
|
-
const maybeNullable = TypeUtils_1.nullableFromUnion(targetType);
|
|
1662
|
+
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(targetType);
|
|
1653
1663
|
if (maybeNullable !== null) {
|
|
1654
1664
|
emitFinish(variable);
|
|
1655
1665
|
}
|
|
@@ -1668,12 +1678,12 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
|
|
|
1668
1678
|
return true;
|
|
1669
1679
|
}
|
|
1670
1680
|
else {
|
|
1671
|
-
return Support_1.panic("Unknown transformer");
|
|
1681
|
+
return (0, Support_1.panic)("Unknown transformer");
|
|
1672
1682
|
}
|
|
1673
1683
|
return false;
|
|
1674
1684
|
}
|
|
1675
1685
|
emitTransformation(converterName, t) {
|
|
1676
|
-
const xf = Support_1.defined(Transformers_1.transformationForType(t));
|
|
1686
|
+
const xf = (0, Support_1.defined)((0, Transformers_1.transformationForType)(t));
|
|
1677
1687
|
const reverse = xf.reverse;
|
|
1678
1688
|
const targetType = xf.targetType;
|
|
1679
1689
|
const xfer = xf.transformer;
|
|
@@ -8,7 +8,7 @@ import { RenderContext } from "../Renderer";
|
|
|
8
8
|
export declare class CrystalTargetLanguage extends TargetLanguage {
|
|
9
9
|
protected makeRenderer(renderContext: RenderContext): CrystalRenderer;
|
|
10
10
|
constructor();
|
|
11
|
-
protected
|
|
11
|
+
protected get defaultIndentation(): string;
|
|
12
12
|
protected getOptions(): Option<any>[];
|
|
13
13
|
}
|
|
14
14
|
export declare class CrystalRenderer extends ConvenienceRenderer {
|
|
@@ -21,7 +21,7 @@ export declare class CrystalRenderer extends ConvenienceRenderer {
|
|
|
21
21
|
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
22
22
|
protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
|
|
23
23
|
protected forbiddenForEnumCases(_e: EnumType, _enumName: Name): ForbiddenWordsInfo;
|
|
24
|
-
protected
|
|
24
|
+
protected get commentLineStart(): string;
|
|
25
25
|
private nullableCrystalType;
|
|
26
26
|
protected isImplicitCycleBreaker(t: Type): boolean;
|
|
27
27
|
private crystalType;
|