From 547d87868b5999a7977ecc832b96068124607d1f Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 10 Jul 2024 09:21:47 +0800 Subject: [PATCH 01/26] add decorator field --- .../emitter/src/lib/client-model-builder.ts | 1 + .../http-client-csharp/emitter/src/type/input-client.ts | 3 ++- .../emitter/src/type/input-decorated-type.ts | 8 ++++++++ .../emitter/src/type/input-decorator-info.ts | 7 +++++++ .../http-client-csharp/emitter/src/type/input-type.ts | 3 ++- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 packages/http-client-csharp/emitter/src/type/input-decorated-type.ts create mode 100644 packages/http-client-csharp/emitter/src/type/input-decorator-info.ts diff --git a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts index 3225b689fc4..b02b00026af 100644 --- a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts +++ b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts @@ -258,6 +258,7 @@ export function createModelForService( Creatable: client.kind === ClientKind.SdkClient, Parent: parent === undefined ? undefined : getClientName(parent), Parameters: urlParameters, + Decorators: [], } as InputClient; for (const op of operations) { const httpOperation = ignoreDiagnostics(getHttpOperation(program, op)); diff --git a/packages/http-client-csharp/emitter/src/type/input-client.ts b/packages/http-client-csharp/emitter/src/type/input-client.ts index b53dd898ae4..98d975a5b81 100644 --- a/packages/http-client-csharp/emitter/src/type/input-client.ts +++ b/packages/http-client-csharp/emitter/src/type/input-client.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +import { InputDecoratedType } from "./input-decorated-type.js"; import { InputOperation } from "./input-operation.js"; import { InputParameter } from "./input-parameter.js"; import { Protocols } from "./protocols.js"; -export interface InputClient { +export interface InputClient extends InputDecoratedType { Name: string; Description?: string; Operations: InputOperation[]; diff --git a/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts b/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts new file mode 100644 index 00000000000..f9fa44aa23a --- /dev/null +++ b/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +import { InputDecoratorInfo } from "./input-decorator-info.js"; + +export interface InputDecoratedType { + Decorators?: InputDecoratorInfo[]; +} diff --git a/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts b/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts new file mode 100644 index 00000000000..4df19c4bf0b --- /dev/null +++ b/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +export interface InputDecoratorInfo { + Name: string; + Arguments: Record; +} diff --git a/packages/http-client-csharp/emitter/src/type/input-type.ts b/packages/http-client-csharp/emitter/src/type/input-type.ts index 9d25e5c5cd3..6f768ffe2ee 100644 --- a/packages/http-client-csharp/emitter/src/type/input-type.ts +++ b/packages/http-client-csharp/emitter/src/type/input-type.ts @@ -3,10 +3,11 @@ import { AccessFlags, SdkBuiltInKinds } from "@azure-tools/typespec-client-generator-core"; import { DateTimeKnownEncoding, DurationKnownEncoding } from "@typespec/compiler"; +import { InputDecoratedType } from "./input-decorated-type.js"; import { InputEnumTypeValue } from "./input-enum-type-value.js"; import { InputModelProperty } from "./input-model-property.js"; -interface InputTypeBase { +interface InputTypeBase extends InputDecoratedType { Kind: string; Description?: string; Deprecation?: string; From 3fa1d91cf7dbf3965533eae4c2395c8af55e1230 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Thu, 18 Jul 2024 15:10:24 +0800 Subject: [PATCH 02/26] add Decorators field in inputModel --- .../emitter/src/lib/converter.ts | 19 +- .../http-client-csharp/emitter/src/options.ts | 6 + .../emitter/src/type/input-decorated-type.ts | 4 +- .../emitter/src/type/input-decorator-info.ts | 7 - .../emitter/src/type/input-enum-type-value.ts | 4 +- .../emitter/src/type/input-model-property.ts | 3 +- .../emitter/src/type/input-operation.ts | 3 +- .../emitter/src/type/input-parameter.ts | 3 +- .../Unbranded-TypeSpec/Configuration.json | 3 + .../Unbranded-TypeSpec/tspCodeModel.json | 657 ++++++++++++------ 10 files changed, 477 insertions(+), 232 deletions(-) delete mode 100644 packages/http-client-csharp/emitter/src/type/input-decorator-info.ts diff --git a/packages/http-client-csharp/emitter/src/lib/converter.ts b/packages/http-client-csharp/emitter/src/lib/converter.ts index 24fefba81c7..57f265322c6 100644 --- a/packages/http-client-csharp/emitter/src/lib/converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/converter.ts @@ -14,6 +14,7 @@ import { SdkEnumValueType, SdkModelPropertyType, SdkModelType, + SdkTupleType, SdkType, SdkUnionType, UsageFlags, @@ -65,7 +66,7 @@ export function fromSdkType( if (sdkType.kind === "utcDateTime" || sdkType.kind === "offsetDateTime") return fromSdkDateTimeType(sdkType); if (sdkType.kind === "duration") return fromSdkDurationType(sdkType as SdkDurationType); - if (sdkType.kind === "tuple") return fromTupleType(); + if (sdkType.kind === "tuple") return fromTupleType(sdkType as SdkTupleType); // TODO -- only in operations we could have these types, considering we did not adopt getAllOperations from TCGC yet, this should be fine. // we need to resolve these conversions when we adopt getAllOperations if (sdkType.kind === "credential") throw new Error("Credential type is not supported yet."); @@ -95,6 +96,7 @@ export function fromSdkModelType( Deprecation: modelType.deprecation, Description: modelType.description, DiscriminatorValue: modelType.discriminatorValue, + Decorators: modelType.decorators, } as InputModelType; models.set(modelTypeName, inputModelType); @@ -170,6 +172,7 @@ export function fromSdkModelType( flattenedNamePrefixes.length > 0 ? flattenedNamePrefixes.concat(property.name) : undefined, + Decorators: property.decorators, }; return [modelProperty]; @@ -212,6 +215,7 @@ export function fromSdkEnumType( Description: enumType.description, IsExtensible: enumType.isFixed ? false : true, Usage: fromUsageFlags(enumType.usage), + Decorators: enumType.decorators, }; if (addToCollection) enums.set(enumName, newInputEnumType); inputEnumType = newInputEnumType; @@ -224,6 +228,7 @@ function fromSdkDateTimeType(dateTimeType: SdkDatetimeType): InputDateTimeType { Kind: dateTimeType.kind, Encode: dateTimeType.encode, WireType: fromSdkBuiltInType(dateTimeType.wireType), + Decorators: dateTimeType.decorators, }; } @@ -232,13 +237,15 @@ function fromSdkDurationType(durationType: SdkDurationType): InputDurationType { Kind: durationType.kind, Encode: durationType.encode, WireType: fromSdkBuiltInType(durationType.wireType), + Decorators: durationType.decorators, }; } // TODO: tuple is not officially supported -function fromTupleType(): InputPrimitiveType { +function fromTupleType(tupleType: SdkTupleType): InputPrimitiveType { return { Kind: "any", + Decorators: tupleType.decorators, }; } @@ -246,6 +253,7 @@ function fromSdkBuiltInType(builtInType: SdkBuiltInType): InputPrimitiveType { return { Kind: builtInType.kind, Encode: builtInType.encode !== builtInType.kind ? builtInType.encode : undefined, // In TCGC this is required, and when there is no encoding, it just has the same value as kind, we could remove this when TCGC decides to simplify + Decorators: builtInType.decorators, }; } @@ -265,6 +273,7 @@ function fromUnionType( Kind: "union", Name: union.name, VariantTypes: variantTypes, + Decorators: union.decorators, }; } @@ -284,6 +293,7 @@ function fromSdkConstantType( // we might keep constant as-is, instead of creating an enum for it. convertConstantToEnum(constantType, enums, literalTypeContext), Value: constantType.value, + Decorators: constantType.decorators, }; function convertConstantToEnum( @@ -313,6 +323,7 @@ function fromSdkConstantType( Description: `The ${enumName}`, // TODO -- what should we put here? IsExtensible: true, Usage: "None", // will be updated later + Decorators: constantType.decorators, }; enums.set(enumName, enumType); return enumType; @@ -332,6 +343,7 @@ function fromSdkEnumValueTypeToConstantType( ? fromSdkBuiltInType(enumValueType.valueType as SdkBuiltInType) // TODO: TCGC fix : fromSdkEnumType(enumValueType.enumType, context, enums), Value: enumValueType.value, + Decorators: enumValueType.decorators, }; } @@ -340,6 +352,7 @@ function fromSdkEnumValueType(enumValueType: SdkEnumValueType): InputEnumTypeVal Name: enumValueType.name, Value: enumValueType.value, Description: enumValueType.description, + Decorators: enumValueType.decorators, }; } @@ -353,6 +366,7 @@ function fromSdkDictionaryType( Kind: "dict", KeyType: fromSdkType(dictionaryType.keyType, context, models, enums), ValueType: fromSdkType(dictionaryType.valueType, context, models, enums), + Decorators: dictionaryType.decorators, }; } @@ -367,6 +381,7 @@ function fromSdkArrayType( Name: arrayType.name, ValueType: fromSdkType(arrayType.valueType, context, models, enums), CrossLanguageDefinitionId: arrayType.crossLanguageDefinitionId, + Decorators: arrayType.decorators, }; } diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index 6721581459d..1775bedf237 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -32,6 +32,7 @@ export interface NetEmitterOptions extends SdkEmitterOptions { "use-model-reader-writer"?: boolean; "disable-xml-docs"?: boolean; "plugin-name"?: string; + decoratorsAllowList?: string[]; } export const NetEmitterOptionsSchema: JSONSchemaType = { @@ -105,6 +106,11 @@ export const NetEmitterOptionsSchema: JSONSchemaType = { "use-model-reader-writer": { type: "boolean", nullable: true }, "disable-xml-docs": { type: "boolean", nullable: true }, "plugin-name": { type: "string", nullable: true }, + decoratorsAllowList: { + type: "array", + nullable: true, + items: { type: "string" }, + }, }, required: [], }; diff --git a/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts b/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts index f9fa44aa23a..2a12c6b6106 100644 --- a/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts +++ b/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputDecoratorInfo } from "./input-decorator-info.js"; +import { DecoratorInfo } from "@azure-tools/typespec-client-generator-core"; export interface InputDecoratedType { - Decorators?: InputDecoratorInfo[]; + Decorators?: DecoratorInfo[]; } diff --git a/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts b/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts deleted file mode 100644 index 4df19c4bf0b..00000000000 --- a/packages/http-client-csharp/emitter/src/type/input-decorator-info.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -export interface InputDecoratorInfo { - Name: string; - Arguments: Record; -} diff --git a/packages/http-client-csharp/emitter/src/type/input-enum-type-value.ts b/packages/http-client-csharp/emitter/src/type/input-enum-type-value.ts index a8bccb84636..f97c7f5913d 100644 --- a/packages/http-client-csharp/emitter/src/type/input-enum-type-value.ts +++ b/packages/http-client-csharp/emitter/src/type/input-enum-type-value.ts @@ -1,7 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -export interface InputEnumTypeValue { +import { InputDecoratedType } from "./input-decorated-type.js"; + +export interface InputEnumTypeValue extends InputDecoratedType { Name: string; Value: any; Description?: string; diff --git a/packages/http-client-csharp/emitter/src/type/input-model-property.ts b/packages/http-client-csharp/emitter/src/type/input-model-property.ts index e23d18c58d7..0bfd8d02b5e 100644 --- a/packages/http-client-csharp/emitter/src/type/input-model-property.ts +++ b/packages/http-client-csharp/emitter/src/type/input-model-property.ts @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +import { InputDecoratedType } from "./input-decorated-type.js"; import { InputType } from "./input-type.js"; -export interface InputModelProperty { +export interface InputModelProperty extends InputDecoratedType { Name: string; SerializedName: string; Description: string; diff --git a/packages/http-client-csharp/emitter/src/type/input-operation.ts b/packages/http-client-csharp/emitter/src/type/input-operation.ts index 3baeec5d15b..d284c9de542 100644 --- a/packages/http-client-csharp/emitter/src/type/input-operation.ts +++ b/packages/http-client-csharp/emitter/src/type/input-operation.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. import { BodyMediaType } from "./body-media-type.js"; +import { InputDecoratedType } from "./input-decorated-type.js"; import { InputParameter } from "./input-parameter.js"; import { OperationLongRunning } from "./operation-long-running.js"; import { OperationPaging } from "./operation-paging.js"; @@ -14,7 +15,7 @@ export interface Paging { NextPageMethod?: string; } -export interface InputOperation { +export interface InputOperation extends InputDecoratedType { Name: string; ResourceName?: string; Summary?: string; diff --git a/packages/http-client-csharp/emitter/src/type/input-parameter.ts b/packages/http-client-csharp/emitter/src/type/input-parameter.ts index 5a5660fb4e0..6b7754eb35b 100644 --- a/packages/http-client-csharp/emitter/src/type/input-parameter.ts +++ b/packages/http-client-csharp/emitter/src/type/input-parameter.ts @@ -2,13 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for license information. import { InputConstant } from "./input-constant.js"; +import { InputDecoratedType } from "./input-decorated-type.js"; import { InputOperationParameterKind } from "./input-operation-parameter-kind.js"; import { InputType } from "./input-type.js"; import { RequestLocation } from "./request-location.js"; //TODO: Define VirtualParameter for HLC export interface VirtualParameter {} -export interface InputParameter { +export interface InputParameter extends InputDecoratedType { Name: string; NameInRequest: string; Description?: string; diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json index 166195e5f8d..d2fc4ef75c7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json @@ -2,5 +2,8 @@ "output-folder": ".", "namespace": "UnbrandedTypeSpec", "library-name": "UnbrandedTypeSpec", + "head-as-boolean": true, + "deserialize-null-collection-as-null-value": true, + "generate-test-project": true, "use-model-reader-writer": true } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json index d7dc8f7cb33..d245369727f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json @@ -9,7 +9,8 @@ "Name": "Thing_requiredLiteralString", "ValueType": { "$id": "3", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { @@ -22,7 +23,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_requiredLiteralString", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "5", @@ -30,7 +32,8 @@ "Name": "Thing_requiredLiteralInt", "ValueType": { "$id": "6", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { @@ -43,7 +46,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_requiredLiteralInt", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "8", @@ -51,7 +55,8 @@ "Name": "Thing_requiredLiteralFloat", "ValueType": { "$id": "9", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { @@ -64,7 +69,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_requiredLiteralFloat", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "11", @@ -72,7 +78,8 @@ "Name": "Thing_optionalLiteralString", "ValueType": { "$id": "12", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { @@ -85,7 +92,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_optionalLiteralString", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "14", @@ -93,7 +101,8 @@ "Name": "Thing_optionalLiteralInt", "ValueType": { "$id": "15", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { @@ -106,7 +115,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_optionalLiteralInt", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "17", @@ -114,7 +124,8 @@ "Name": "Thing_optionalLiteralFloat", "ValueType": { "$id": "18", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { @@ -127,7 +138,8 @@ "CrossLanguageDefinitionId": "", "Description": "The Thing_optionalLiteralFloat", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "20", @@ -136,28 +148,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.StringFixedEnum", "ValueType": { "$id": "21", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { "$id": "22", "Name": "One", - "Value": "1" + "Value": "1", + "Decorators": [] }, { "$id": "23", "Name": "Two", - "Value": "2" + "Value": "2", + "Decorators": [] }, { "$id": "24", "Name": "Four", - "Value": "4" + "Value": "4", + "Decorators": [] } ], "Description": "Simple enum", "IsExtensible": false, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "25", @@ -166,28 +183,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.StringExtensibleEnum", "ValueType": { "$id": "26", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { "$id": "27", "Name": "One", - "Value": "1" + "Value": "1", + "Decorators": [] }, { "$id": "28", "Name": "Two", - "Value": "2" + "Value": "2", + "Decorators": [] }, { "$id": "29", "Name": "Four", - "Value": "4" + "Value": "4", + "Decorators": [] } ], "Description": "Extensible enum", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "30", @@ -196,28 +218,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.IntExtensibleEnum", "ValueType": { "$id": "31", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { "$id": "32", "Name": "One", - "Value": 1 + "Value": 1, + "Decorators": [] }, { "$id": "33", "Name": "Two", - "Value": 2 + "Value": 2, + "Decorators": [] }, { "$id": "34", "Name": "Four", - "Value": 4 + "Value": 4, + "Decorators": [] } ], "Description": "Int based extensible enum", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "35", @@ -226,28 +253,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.FloatExtensibleEnum", "ValueType": { "$id": "36", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { "$id": "37", "Name": "OneDotOne", - "Value": 1.1 + "Value": 1.1, + "Decorators": [] }, { "$id": "38", "Name": "TwoDotTwo", - "Value": 2.2 + "Value": 2.2, + "Decorators": [] }, { "$id": "39", "Name": "FourDotFour", - "Value": 4.4 + "Value": 4.4, + "Decorators": [] } ], "Description": "Float based extensible enum", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "40", @@ -256,28 +288,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.FloatExtensibleEnumWithIntValue", "ValueType": { "$id": "41", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { "$id": "42", "Name": "One", - "Value": 1 + "Value": 1, + "Decorators": [] }, { "$id": "43", "Name": "Two", - "Value": 2 + "Value": 2, + "Decorators": [] }, { "$id": "44", "Name": "Four", - "Value": 4 + "Value": 4, + "Decorators": [] } ], "Description": "float fixed enum", "IsExtensible": true, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "45", @@ -286,28 +323,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.FloatFixedEnum", "ValueType": { "$id": "46", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { "$id": "47", "Name": "OneDotOne", - "Value": 1.1 + "Value": 1.1, + "Decorators": [] }, { "$id": "48", "Name": "TwoDotTwo", - "Value": 2.2 + "Value": 2.2, + "Decorators": [] }, { "$id": "49", "Name": "FourDotFour", - "Value": 4.4 + "Value": 4.4, + "Decorators": [] } ], "Description": "float fixed enum", "IsExtensible": false, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "50", @@ -316,28 +358,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.FloatFixedEnumWithIntValue", "ValueType": { "$id": "51", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { "$id": "52", "Name": "One", - "Value": 1 + "Value": 1, + "Decorators": [] }, { "$id": "53", "Name": "Two", - "Value": 2 + "Value": 2, + "Decorators": [] }, { "$id": "54", "Name": "Four", - "Value": 4 + "Value": 4, + "Decorators": [] } ], "Description": "float fixed enum", "IsExtensible": false, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "55", @@ -346,28 +393,33 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.IntFixedEnum", "ValueType": { "$id": "56", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { "$id": "57", "Name": "One", - "Value": 1 + "Value": 1, + "Decorators": [] }, { "$id": "58", "Name": "Two", - "Value": 2 + "Value": 2, + "Decorators": [] }, { "$id": "59", "Name": "Four", - "Value": 4 + "Value": 4, + "Decorators": [] } ], "Description": "int fixed enum", "IsExtensible": false, - "Usage": "RoundTrip" + "Usage": "RoundTrip", + "Decorators": [] }, { "$id": "60", @@ -375,7 +427,8 @@ "Name": "AnonymousBodyRequest_requiredLiteralString", "ValueType": { "$id": "61", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { @@ -388,7 +441,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_requiredLiteralString", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] }, { "$id": "63", @@ -396,7 +450,8 @@ "Name": "AnonymousBodyRequest_requiredLiteralInt", "ValueType": { "$id": "64", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { @@ -409,7 +464,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_requiredLiteralInt", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] }, { "$id": "66", @@ -417,7 +473,8 @@ "Name": "AnonymousBodyRequest_requiredLiteralFloat", "ValueType": { "$id": "67", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { @@ -430,7 +487,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_requiredLiteralFloat", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] }, { "$id": "69", @@ -438,7 +496,8 @@ "Name": "AnonymousBodyRequest_optionalLiteralString", "ValueType": { "$id": "70", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Values": [ { @@ -451,7 +510,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_optionalLiteralString", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] }, { "$id": "72", @@ -459,7 +519,8 @@ "Name": "AnonymousBodyRequest_optionalLiteralInt", "ValueType": { "$id": "73", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "Values": [ { @@ -472,7 +533,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_optionalLiteralInt", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] }, { "$id": "75", @@ -480,7 +542,8 @@ "Name": "AnonymousBodyRequest_optionalLiteralFloat", "ValueType": { "$id": "76", - "Kind": "float32" + "Kind": "float32", + "Decorators": [] }, "Values": [ { @@ -493,7 +556,8 @@ "CrossLanguageDefinitionId": "", "Description": "The AnonymousBodyRequest_optionalLiteralFloat", "IsExtensible": true, - "Usage": "Input" + "Usage": "Input", + "Decorators": [] } ], "Models": [ @@ -504,6 +568,7 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.Thing", "Usage": "RoundTrip", "Description": "A model with a few properties of literal types", + "Decorators": [], "Properties": [ { "$id": "79", @@ -512,10 +577,12 @@ "Description": "name of the Thing", "Type": { "$id": "80", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "81", @@ -529,7 +596,8 @@ "VariantTypes": [ { "$id": "83", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, { "$id": "84", @@ -537,18 +605,23 @@ "Name": "Array", "ValueType": { "$id": "85", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, { "$id": "86", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] } - ] + ], + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "87", @@ -561,10 +634,12 @@ "ValueType": { "$ref": "2" }, - "Value": "accept" + "Value": "accept", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "89", @@ -577,10 +652,12 @@ "ValueType": { "$ref": "5" }, - "Value": 123 + "Value": 123, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "91", @@ -593,10 +670,12 @@ "ValueType": { "$ref": "8" }, - "Value": 1.23 + "Value": 1.23, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "93", @@ -608,12 +687,15 @@ "Kind": "constant", "ValueType": { "$id": "95", - "Kind": "boolean" + "Kind": "boolean", + "Decorators": [] }, - "Value": false + "Value": false, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "96", @@ -626,10 +708,12 @@ "ValueType": { "$ref": "11" }, - "Value": "reject" + "Value": "reject", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "98", @@ -642,10 +726,12 @@ "ValueType": { "$ref": "14" }, - "Value": 456 + "Value": 456, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "100", @@ -658,10 +744,12 @@ "ValueType": { "$ref": "17" }, - "Value": 4.56 + "Value": 4.56, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "102", @@ -673,12 +761,15 @@ "Kind": "constant", "ValueType": { "$id": "104", - "Kind": "boolean" + "Kind": "boolean", + "Decorators": [] }, - "Value": true + "Value": true, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "105", @@ -687,10 +778,12 @@ "Description": "description with xml <|endoftext|>", "Type": { "$id": "106", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "107", @@ -706,13 +799,16 @@ "Name": "Array", "ValueType": { "$id": "110", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] } }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "111", @@ -728,13 +824,16 @@ "Name": "Array", "ValueType": { "$id": "114", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] } }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -745,6 +844,7 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel", "Usage": "RoundTrip", "Description": "this is a roundtrip model", + "Decorators": [], "Properties": [ { "$id": "116", @@ -753,10 +853,12 @@ "Description": "Required string, illustrating a reference type property.", "Type": { "$id": "117", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "118", @@ -765,10 +867,12 @@ "Description": "Required int, illustrating a value type property.", "Type": { "$id": "119", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "120", @@ -782,10 +886,12 @@ "ValueType": { "$ref": "20" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "122", @@ -797,14 +903,17 @@ "Kind": "dict", "KeyType": { "$id": "124", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "ValueType": { "$ref": "25" - } + }, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "125", @@ -815,7 +924,8 @@ "$ref": "78" }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "126", @@ -826,7 +936,8 @@ "$ref": "30" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "127", @@ -840,10 +951,12 @@ "ValueType": { "$ref": "30" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "129", @@ -854,7 +967,8 @@ "$ref": "35" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "130", @@ -865,7 +979,8 @@ "$ref": "40" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "131", @@ -879,10 +994,12 @@ "ValueType": { "$ref": "35" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "133", @@ -893,7 +1010,8 @@ "$ref": "45" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "134", @@ -904,7 +1022,8 @@ "$ref": "50" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "135", @@ -918,10 +1037,12 @@ "ValueType": { "$ref": "45" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "137", @@ -932,7 +1053,8 @@ "$ref": "55" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "138", @@ -946,10 +1068,12 @@ "ValueType": { "$ref": "55" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "140", @@ -960,7 +1084,8 @@ "$ref": "20" }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "141", @@ -969,10 +1094,12 @@ "Description": "required unknown", "Type": { "$id": "142", - "Kind": "any" + "Kind": "any", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "143", @@ -981,10 +1108,12 @@ "Description": "optional unknown", "Type": { "$id": "144", - "Kind": "any" + "Kind": "any", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "145", @@ -996,15 +1125,19 @@ "Kind": "dict", "KeyType": { "$id": "147", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "ValueType": { "$id": "148", - "Kind": "any" - } + "Kind": "any", + "Decorators": [] + }, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "149", @@ -1016,15 +1149,19 @@ "Kind": "dict", "KeyType": { "$id": "151", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "ValueType": { "$id": "152", - "Kind": "any" - } + "Kind": "any", + "Decorators": [] + }, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "153", @@ -1036,15 +1173,19 @@ "Kind": "dict", "KeyType": { "$id": "155", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "ValueType": { "$id": "156", - "Kind": "any" - } + "Kind": "any", + "Decorators": [] + }, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": true + "IsReadOnly": true, + "Decorators": [] }, { "$id": "157", @@ -1056,15 +1197,19 @@ "Kind": "dict", "KeyType": { "$id": "159", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "ValueType": { "$id": "160", - "Kind": "any" - } + "Kind": "any", + "Decorators": [] + }, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": true + "IsReadOnly": true, + "Decorators": [] }, { "$id": "161", @@ -1078,6 +1223,7 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithRequiredNullableProperties", "Usage": "RoundTrip", "Description": "A model with a few required nullable properties", + "Decorators": [], "Properties": [ { "$id": "163", @@ -1089,11 +1235,13 @@ "Kind": "nullable", "Type": { "$id": "165", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] } }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "166", @@ -1108,7 +1256,8 @@ } }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "168", @@ -1123,12 +1272,14 @@ } }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "170", @@ -1138,10 +1289,12 @@ "Type": { "$id": "171", "Kind": "bytes", - "Encode": "base64" + "Encode": "base64", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -1155,6 +1308,7 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.NotFriend", "Usage": "Output", "Description": "this is not a friendly model but with a friendly name", + "Decorators": [], "Properties": [ { "$id": "173", @@ -1163,10 +1317,12 @@ "Description": "name of the NotFriend", "Type": { "$id": "174", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -1177,6 +1333,7 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithProjectedName", "Usage": "Output", "Description": "this is a model with a projected name", + "Decorators": [], "Properties": [ { "$id": "176", @@ -1185,10 +1342,12 @@ "Description": "name of the ModelWithProjectedName", "Type": { "$id": "177", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -1198,6 +1357,7 @@ "Name": "ReturnsAnonymousModelResponse", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.returnsAnonymousModel.Response.anonymous", "Usage": "Output", + "Decorators": [], "Properties": [] }, { @@ -1206,6 +1366,7 @@ "Name": "AnonymousBodyRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.anonymousBody.Request.anonymous", "Usage": "Input", + "Decorators": [], "Properties": [ { "$id": "180", @@ -1214,10 +1375,12 @@ "Description": "name of the Thing", "Type": { "$id": "181", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "182", @@ -1231,7 +1394,8 @@ "VariantTypes": [ { "$id": "184", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, { "$id": "185", @@ -1239,18 +1403,23 @@ "Name": "Array", "ValueType": { "$id": "186", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, { "$id": "187", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] } - ] + ], + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "188", @@ -1263,10 +1432,12 @@ "ValueType": { "$ref": "60" }, - "Value": "accept" + "Value": "accept", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "190", @@ -1279,10 +1450,12 @@ "ValueType": { "$ref": "63" }, - "Value": 123 + "Value": 123, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "192", @@ -1295,10 +1468,12 @@ "ValueType": { "$ref": "66" }, - "Value": 1.23 + "Value": 1.23, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "194", @@ -1310,12 +1485,15 @@ "Kind": "constant", "ValueType": { "$id": "196", - "Kind": "boolean" + "Kind": "boolean", + "Decorators": [] }, - "Value": false + "Value": false, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "197", @@ -1328,10 +1506,12 @@ "ValueType": { "$ref": "69" }, - "Value": "reject" + "Value": "reject", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "199", @@ -1344,10 +1524,12 @@ "ValueType": { "$ref": "72" }, - "Value": 456 + "Value": 456, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "201", @@ -1360,10 +1542,12 @@ "ValueType": { "$ref": "75" }, - "Value": 4.56 + "Value": 4.56, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "203", @@ -1375,12 +1559,15 @@ "Kind": "constant", "ValueType": { "$id": "205", - "Kind": "boolean" + "Kind": "boolean", + "Decorators": [] }, - "Value": true + "Value": true, + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "206", @@ -1389,10 +1576,12 @@ "Description": "description with xml <|endoftext|>", "Type": { "$id": "207", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "208", @@ -1408,13 +1597,16 @@ "Name": "Array", "ValueType": { "$id": "211", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] } }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "212", @@ -1430,13 +1622,16 @@ "Name": "Array", "ValueType": { "$id": "215", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] } }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -1446,6 +1641,7 @@ "Name": "FriendlyModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.friendlyModel.Request.anonymous", "Usage": "Input", + "Decorators": [], "Properties": [ { "$id": "217", @@ -1454,10 +1650,12 @@ "Description": "name of the NotFriend", "Type": { "$id": "218", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -1467,6 +1665,7 @@ "Name": "ProjectedNameModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.projectedNameModel.Request.anonymous", "Usage": "Input", + "Decorators": [], "Properties": [ { "$id": "220", @@ -1475,10 +1674,12 @@ "Description": "name of the ModelWithProjectedName", "Type": { "$id": "221", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } @@ -1520,7 +1721,8 @@ "NameInRequest": "head-parameter", "Type": { "$id": "227", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Header", "IsRequired": true, @@ -1538,7 +1740,8 @@ "NameInRequest": "queryParameter", "Type": { "$id": "229", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Query", "IsRequired": true, @@ -1556,7 +1759,8 @@ "NameInRequest": "optionalQuery", "Type": { "$id": "231", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Query", "IsRequired": false, @@ -1617,7 +1821,7 @@ "Path": "/hello", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": true + "GenerateConvenienceMethod": false }, { "$id": "236", @@ -1635,7 +1839,8 @@ "NameInRequest": "p1", "Type": { "$id": "238", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Header", "IsRequired": true, @@ -1656,9 +1861,11 @@ "Kind": "constant", "ValueType": { "$id": "241", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, - "Value": "text/plain" + "Value": "text/plain", + "Decorators": [] }, "Location": "Header", "DefaultValue": { @@ -1683,7 +1890,8 @@ "NameInRequest": "p2", "Type": { "$id": "244", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Path", "IsRequired": true, @@ -1782,7 +1990,8 @@ "NameInRequest": "p1", "Type": { "$id": "252", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Header", "IsRequired": true, @@ -1800,7 +2009,8 @@ "NameInRequest": "p2", "Type": { "$id": "254", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Path", "IsRequired": true, @@ -2094,9 +2304,11 @@ "Kind": "constant", "ValueType": { "$id": "280", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, - "Value": "test" + "Value": "test", + "Decorators": [] }, "Location": "Header", "DefaultValue": { @@ -2124,9 +2336,11 @@ "Kind": "constant", "ValueType": { "$id": "284", - "Kind": "int32" + "Kind": "int32", + "Decorators": [] }, - "Value": 123 + "Value": 123, + "Decorators": [] }, "Location": "Path", "DefaultValue": { @@ -2154,9 +2368,11 @@ "Kind": "constant", "ValueType": { "$id": "288", - "Kind": "boolean" + "Kind": "boolean", + "Decorators": [] }, - "Value": true + "Value": true, + "Decorators": [] }, "Location": "Query", "DefaultValue": { @@ -2246,8 +2462,10 @@ "Encode": "rfc3339", "WireType": { "$id": "297", - "Kind": "string" - } + "Kind": "string", + "Decorators": [] + }, + "Decorators": [] }, "Location": "Path", "IsRequired": true, @@ -2710,8 +2928,10 @@ "Encode": "rfc7231", "WireType": { "$id": "337", - "Kind": "string" - } + "Kind": "string", + "Decorators": [] + }, + "Decorators": [] }, "Location": "Header", "IsRequired": false, @@ -2766,7 +2986,7 @@ "Path": "/", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": true + "GenerateConvenienceMethod": false }, { "$id": "342", @@ -2980,7 +3200,8 @@ ], "BodyType": { "$id": "361", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "BodyMediaType": "Json", "Headers": [], @@ -2996,7 +3217,7 @@ "Path": "/unknown-value", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": true + "GenerateConvenienceMethod": false }, { "$id": "362", @@ -3175,7 +3396,8 @@ "NameInRequest": "id", "Type": { "$id": "378", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "Location": "Path", "IsRequired": true, @@ -3240,7 +3462,8 @@ { "$ref": "224" } - ] + ], + "Decorators": [] } ], "Auth": { From 5573a8a5e19a796b56dab99b044e21edb01cca91 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 19 Jul 2024 15:11:53 +0800 Subject: [PATCH 03/26] set additionalDecorators --- .../emitter/src/constants.ts | 13 + .../http-client-csharp/emitter/src/emitter.ts | 6 +- .../http-client-csharp/emitter/src/index.ts | 2 +- .../http-client-csharp/emitter/src/options.ts | 6 - .../Unbranded-TypeSpec/Configuration.json | 3 - .../Unbranded-TypeSpec/tspCodeModel.json | 534 +++++++++--------- 6 files changed, 290 insertions(+), 274 deletions(-) diff --git a/packages/http-client-csharp/emitter/src/constants.ts b/packages/http-client-csharp/emitter/src/constants.ts index 254849d3819..6941ce64fa6 100644 --- a/packages/http-client-csharp/emitter/src/constants.ts +++ b/packages/http-client-csharp/emitter/src/constants.ts @@ -7,3 +7,16 @@ export const projectedNameClientKey = "client"; export const mockApiVersion = "0000-00-00"; export const tspOutputFileName = "tspCodeModel.json"; export const configurationFileName = "Configuration.json"; +export let createSDKContextoptions = { + additionalDecorators: ["TypeSpec\\.@projectedName"], +}; +export function getSDKContextOptions(): any { + return createSDKContextoptions; +} +export function setSDKContextOptions(options: any): void { + createSDKContextoptions = options; +} +export function addAdditionalDecorators(additionalDecorators: string[]): void { + createSDKContextoptions.additionalDecorators = + createSDKContextoptions.additionalDecorators.concat(additionalDecorators); +} diff --git a/packages/http-client-csharp/emitter/src/emitter.ts b/packages/http-client-csharp/emitter/src/emitter.ts index 1932546585e..24220eb4056 100644 --- a/packages/http-client-csharp/emitter/src/emitter.ts +++ b/packages/http-client-csharp/emitter/src/emitter.ts @@ -16,7 +16,7 @@ import fs, { statSync } from "fs"; import { PreserveType, stringifyRefs } from "json-serialize-refs"; import { dirname } from "path"; import { fileURLToPath } from "url"; -import { configurationFileName, tspOutputFileName } from "./constants.js"; +import { configurationFileName, createSDKContextoptions, tspOutputFileName } from "./constants.js"; import { createModel } from "./lib/client-model-builder.js"; import { LoggerLevel } from "./lib/log-level.js"; import { Logger } from "./lib/logger.js"; @@ -53,7 +53,9 @@ export async function $onEmit(context: EmitContext) { if (!program.compilerOptions.noEmit && !program.hasError()) { // Write out the dotnet model to the output path - const sdkContext = createSdkContext(context, "@typespec/http-client-csharp"); + const sdkContext = createSdkContext(context, "@typespec/http-client-csharp", { + ...createSDKContextoptions, + }); const root = createModel(sdkContext); if ( context.program.diagnostics.length > 0 && diff --git a/packages/http-client-csharp/emitter/src/index.ts b/packages/http-client-csharp/emitter/src/index.ts index cd6e7d09568..00a0e420a44 100644 --- a/packages/http-client-csharp/emitter/src/index.ts +++ b/packages/http-client-csharp/emitter/src/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -export { configurationFileName, tspOutputFileName } from "./constants.js"; +export { addAdditionalDecorators, configurationFileName, tspOutputFileName } from "./constants.js"; export * from "./emitter.js"; export { createDiagnostic, getTracer, reportDiagnostic } from "./lib/lib.js"; export { LoggerLevel } from "./lib/log-level.js"; diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index 1775bedf237..6721581459d 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -32,7 +32,6 @@ export interface NetEmitterOptions extends SdkEmitterOptions { "use-model-reader-writer"?: boolean; "disable-xml-docs"?: boolean; "plugin-name"?: string; - decoratorsAllowList?: string[]; } export const NetEmitterOptionsSchema: JSONSchemaType = { @@ -106,11 +105,6 @@ export const NetEmitterOptionsSchema: JSONSchemaType = { "use-model-reader-writer": { type: "boolean", nullable: true }, "disable-xml-docs": { type: "boolean", nullable: true }, "plugin-name": { type: "string", nullable: true }, - decoratorsAllowList: { - type: "array", - nullable: true, - items: { type: "string" }, - }, }, required: [], }; diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json index d2fc4ef75c7..166195e5f8d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/Configuration.json @@ -2,8 +2,5 @@ "output-folder": ".", "namespace": "UnbrandedTypeSpec", "library-name": "UnbrandedTypeSpec", - "head-as-boolean": true, - "deserialize-null-collection-as-null-value": true, - "generate-test-project": true, "use-model-reader-writer": true } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json index d245369727f..489eb36baf6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json @@ -1333,15 +1333,25 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithProjectedName", "Usage": "Output", "Description": "this is a model with a projected name", - "Decorators": [], - "Properties": [ + "Decorators": [ { "$id": "176", + "name": "TypeSpec.@projectedName", + "arguments": { + "$id": "177", + "targetName": "client", + "projectedName": "ProjectedModel" + } + } + ], + "Properties": [ + { + "$id": "178", "Name": "name", "SerializedName": "name", "Description": "name of the ModelWithProjectedName", "Type": { - "$id": "177", + "$id": "179", "Kind": "string", "Decorators": [] }, @@ -1352,7 +1362,7 @@ ] }, { - "$id": "178", + "$id": "180", "Kind": "model", "Name": "ReturnsAnonymousModelResponse", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.returnsAnonymousModel.Response.anonymous", @@ -1361,7 +1371,7 @@ "Properties": [] }, { - "$id": "179", + "$id": "181", "Kind": "model", "Name": "AnonymousBodyRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.anonymousBody.Request.anonymous", @@ -1369,12 +1379,12 @@ "Decorators": [], "Properties": [ { - "$id": "180", + "$id": "182", "Name": "name", "SerializedName": "name", "Description": "name of the Thing", "Type": { - "$id": "181", + "$id": "183", "Kind": "string", "Decorators": [] }, @@ -1383,26 +1393,26 @@ "Decorators": [] }, { - "$id": "182", + "$id": "184", "Name": "requiredUnion", "SerializedName": "requiredUnion", "Description": "required Union", "Type": { - "$id": "183", + "$id": "185", "Kind": "union", "Name": "ThingRequiredUnion", "VariantTypes": [ { - "$id": "184", + "$id": "186", "Kind": "string", "Decorators": [] }, { - "$id": "185", + "$id": "187", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "186", + "$id": "188", "Kind": "string", "Decorators": [] }, @@ -1410,7 +1420,7 @@ "Decorators": [] }, { - "$id": "187", + "$id": "189", "Kind": "int32", "Decorators": [] } @@ -1422,12 +1432,12 @@ "Decorators": [] }, { - "$id": "188", + "$id": "190", "Name": "requiredLiteralString", "SerializedName": "requiredLiteralString", "Description": "required literal string", "Type": { - "$id": "189", + "$id": "191", "Kind": "constant", "ValueType": { "$ref": "60" @@ -1440,12 +1450,12 @@ "Decorators": [] }, { - "$id": "190", + "$id": "192", "Name": "requiredLiteralInt", "SerializedName": "requiredLiteralInt", "Description": "required literal int", "Type": { - "$id": "191", + "$id": "193", "Kind": "constant", "ValueType": { "$ref": "63" @@ -1458,12 +1468,12 @@ "Decorators": [] }, { - "$id": "192", + "$id": "194", "Name": "requiredLiteralFloat", "SerializedName": "requiredLiteralFloat", "Description": "required literal float", "Type": { - "$id": "193", + "$id": "195", "Kind": "constant", "ValueType": { "$ref": "66" @@ -1476,15 +1486,15 @@ "Decorators": [] }, { - "$id": "194", + "$id": "196", "Name": "requiredLiteralBool", "SerializedName": "requiredLiteralBool", "Description": "required literal bool", "Type": { - "$id": "195", + "$id": "197", "Kind": "constant", "ValueType": { - "$id": "196", + "$id": "198", "Kind": "boolean", "Decorators": [] }, @@ -1496,12 +1506,12 @@ "Decorators": [] }, { - "$id": "197", + "$id": "199", "Name": "optionalLiteralString", "SerializedName": "optionalLiteralString", "Description": "optional literal string", "Type": { - "$id": "198", + "$id": "200", "Kind": "constant", "ValueType": { "$ref": "69" @@ -1514,12 +1524,12 @@ "Decorators": [] }, { - "$id": "199", + "$id": "201", "Name": "optionalLiteralInt", "SerializedName": "optionalLiteralInt", "Description": "optional literal int", "Type": { - "$id": "200", + "$id": "202", "Kind": "constant", "ValueType": { "$ref": "72" @@ -1532,12 +1542,12 @@ "Decorators": [] }, { - "$id": "201", + "$id": "203", "Name": "optionalLiteralFloat", "SerializedName": "optionalLiteralFloat", "Description": "optional literal float", "Type": { - "$id": "202", + "$id": "204", "Kind": "constant", "ValueType": { "$ref": "75" @@ -1550,15 +1560,15 @@ "Decorators": [] }, { - "$id": "203", + "$id": "205", "Name": "optionalLiteralBool", "SerializedName": "optionalLiteralBool", "Description": "optional literal bool", "Type": { - "$id": "204", + "$id": "206", "Kind": "constant", "ValueType": { - "$id": "205", + "$id": "207", "Kind": "boolean", "Decorators": [] }, @@ -1570,12 +1580,12 @@ "Decorators": [] }, { - "$id": "206", + "$id": "208", "Name": "requiredBadDescription", "SerializedName": "requiredBadDescription", "Description": "description with xml <|endoftext|>", "Type": { - "$id": "207", + "$id": "209", "Kind": "string", "Decorators": [] }, @@ -1584,19 +1594,19 @@ "Decorators": [] }, { - "$id": "208", + "$id": "210", "Name": "optionalNullableList", "SerializedName": "optionalNullableList", "Description": "optional nullable collection", "Type": { - "$id": "209", + "$id": "211", "Kind": "nullable", "Type": { - "$id": "210", + "$id": "212", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "211", + "$id": "213", "Kind": "int32", "Decorators": [] }, @@ -1609,19 +1619,19 @@ "Decorators": [] }, { - "$id": "212", + "$id": "214", "Name": "requiredNullableList", "SerializedName": "requiredNullableList", "Description": "required nullable collection", "Type": { - "$id": "213", + "$id": "215", "Kind": "nullable", "Type": { - "$id": "214", + "$id": "216", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "215", + "$id": "217", "Kind": "int32", "Decorators": [] }, @@ -1636,7 +1646,7 @@ ] }, { - "$id": "216", + "$id": "218", "Kind": "model", "Name": "FriendlyModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.friendlyModel.Request.anonymous", @@ -1644,12 +1654,12 @@ "Decorators": [], "Properties": [ { - "$id": "217", + "$id": "219", "Name": "name", "SerializedName": "name", "Description": "name of the NotFriend", "Type": { - "$id": "218", + "$id": "220", "Kind": "string", "Decorators": [] }, @@ -1660,7 +1670,7 @@ ] }, { - "$id": "219", + "$id": "221", "Kind": "model", "Name": "ProjectedNameModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.projectedNameModel.Request.anonymous", @@ -1668,12 +1678,12 @@ "Decorators": [], "Properties": [ { - "$id": "220", + "$id": "222", "Name": "name", "SerializedName": "name", "Description": "name of the ModelWithProjectedName", "Type": { - "$id": "221", + "$id": "223", "Kind": "string", "Decorators": [] }, @@ -1686,23 +1696,23 @@ ], "Clients": [ { - "$id": "222", + "$id": "224", "Name": "UnbrandedTypeSpecClient", "Description": "This is a sample typespec project.", "Operations": [ { - "$id": "223", + "$id": "225", "Name": "sayHi", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi", "Accessibility": "public", "Parameters": [ { - "$id": "224", + "$id": "226", "Name": "unbrandedTypeSpecUrl", "NameInRequest": "unbrandedTypeSpecUrl", "Type": { - "$id": "225", + "$id": "227", "Kind": "url" }, "Location": "Uri", @@ -1716,11 +1726,11 @@ "Kind": "Client" }, { - "$id": "226", + "$id": "228", "Name": "headParameter", "NameInRequest": "head-parameter", "Type": { - "$id": "227", + "$id": "229", "Kind": "string", "Decorators": [] }, @@ -1735,11 +1745,11 @@ "Kind": "Method" }, { - "$id": "228", + "$id": "230", "Name": "queryParameter", "NameInRequest": "queryParameter", "Type": { - "$id": "229", + "$id": "231", "Kind": "string", "Decorators": [] }, @@ -1754,11 +1764,11 @@ "Kind": "Method" }, { - "$id": "230", + "$id": "232", "Name": "optionalQuery", "NameInRequest": "optionalQuery", "Type": { - "$id": "231", + "$id": "233", "Kind": "string", "Decorators": [] }, @@ -1773,11 +1783,11 @@ "Kind": "Method" }, { - "$id": "232", + "$id": "234", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "233", + "$id": "235", "Kind": "string" }, "Location": "Header", @@ -1790,9 +1800,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "234", + "$id": "236", "Type": { - "$ref": "233" + "$ref": "235" }, "Value": "application/json" } @@ -1800,7 +1810,7 @@ ], "Responses": [ { - "$id": "235", + "$id": "237", "StatusCodes": [ 200 ], @@ -1821,24 +1831,24 @@ "Path": "/hello", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": false + "GenerateConvenienceMethod": true }, { - "$id": "236", + "$id": "238", "Name": "helloAgain", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi again", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "237", + "$id": "239", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "238", + "$id": "240", "Kind": "string", "Decorators": [] }, @@ -1853,14 +1863,14 @@ "Kind": "Method" }, { - "$id": "239", + "$id": "241", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "240", + "$id": "242", "Kind": "constant", "ValueType": { - "$id": "241", + "$id": "243", "Kind": "string", "Decorators": [] }, @@ -1869,9 +1879,9 @@ }, "Location": "Header", "DefaultValue": { - "$id": "242", + "$id": "244", "Type": { - "$ref": "240" + "$ref": "242" }, "Value": "text/plain" }, @@ -1885,11 +1895,11 @@ "Kind": "Constant" }, { - "$id": "243", + "$id": "245", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "244", + "$id": "246", "Kind": "string", "Decorators": [] }, @@ -1904,7 +1914,7 @@ "Kind": "Method" }, { - "$id": "245", + "$id": "247", "Name": "action", "NameInRequest": "action", "Type": { @@ -1921,11 +1931,11 @@ "Kind": "Method" }, { - "$id": "246", + "$id": "248", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "247", + "$id": "249", "Kind": "string" }, "Location": "Header", @@ -1938,9 +1948,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "248", + "$id": "250", "Type": { - "$ref": "247" + "$ref": "249" }, "Value": "application/json" } @@ -1948,7 +1958,7 @@ ], "Responses": [ { - "$id": "249", + "$id": "251", "StatusCodes": [ 200 ], @@ -1975,21 +1985,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "250", + "$id": "252", "Name": "noContentType", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi again", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "251", + "$id": "253", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "252", + "$id": "254", "Kind": "string", "Decorators": [] }, @@ -2004,11 +2014,11 @@ "Kind": "Method" }, { - "$id": "253", + "$id": "255", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "254", + "$id": "256", "Kind": "string", "Decorators": [] }, @@ -2023,7 +2033,7 @@ "Kind": "Method" }, { - "$id": "255", + "$id": "257", "Name": "action", "NameInRequest": "action", "Type": { @@ -2040,11 +2050,11 @@ "Kind": "Method" }, { - "$id": "256", + "$id": "258", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "257", + "$id": "259", "Kind": "string" }, "Location": "Header", @@ -2057,19 +2067,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "258", + "$id": "260", "Type": { - "$ref": "257" + "$ref": "259" }, "Value": "application/json" } }, { - "$id": "259", + "$id": "261", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "260", + "$id": "262", "Kind": "string" }, "Location": "Header", @@ -2082,9 +2092,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "261", + "$id": "263", "Type": { - "$ref": "260" + "$ref": "262" }, "Value": "application/json" } @@ -2092,7 +2102,7 @@ ], "Responses": [ { - "$id": "262", + "$id": "264", "StatusCodes": [ 200 ], @@ -2119,21 +2129,21 @@ "GenerateConvenienceMethod": false }, { - "$id": "263", + "$id": "265", "Name": "helloDemo2", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi in demo2", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "264", + "$id": "266", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "265", + "$id": "267", "Kind": "string" }, "Location": "Header", @@ -2146,9 +2156,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "266", + "$id": "268", "Type": { - "$ref": "265" + "$ref": "267" }, "Value": "application/json" } @@ -2156,7 +2166,7 @@ ], "Responses": [ { - "$id": "267", + "$id": "269", "StatusCodes": [ 200 ], @@ -2180,17 +2190,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "268", + "$id": "270", "Name": "createLiteral", "ResourceName": "UnbrandedTypeSpec", "Description": "Create with literal value", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "269", + "$id": "271", "Name": "body", "NameInRequest": "body", "Type": { @@ -2207,11 +2217,11 @@ "Kind": "Method" }, { - "$id": "270", + "$id": "272", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "271", + "$id": "273", "Kind": "string" }, "Location": "Header", @@ -2224,19 +2234,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "272", + "$id": "274", "Type": { - "$ref": "271" + "$ref": "273" }, "Value": "application/json" } }, { - "$id": "273", + "$id": "275", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "274", + "$id": "276", "Kind": "string" }, "Location": "Header", @@ -2249,9 +2259,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "275", + "$id": "277", "Type": { - "$ref": "274" + "$ref": "276" }, "Value": "application/json" } @@ -2259,7 +2269,7 @@ ], "Responses": [ { - "$id": "276", + "$id": "278", "StatusCodes": [ 200 ], @@ -2286,24 +2296,24 @@ "GenerateConvenienceMethod": true }, { - "$id": "277", + "$id": "279", "Name": "helloLiteral", "ResourceName": "UnbrandedTypeSpec", "Description": "Send literal parameters", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "278", + "$id": "280", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "279", + "$id": "281", "Kind": "constant", "ValueType": { - "$id": "280", + "$id": "282", "Kind": "string", "Decorators": [] }, @@ -2312,9 +2322,9 @@ }, "Location": "Header", "DefaultValue": { - "$id": "281", + "$id": "283", "Type": { - "$ref": "279" + "$ref": "281" }, "Value": "test" }, @@ -2328,14 +2338,14 @@ "Kind": "Constant" }, { - "$id": "282", + "$id": "284", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "283", + "$id": "285", "Kind": "constant", "ValueType": { - "$id": "284", + "$id": "286", "Kind": "int32", "Decorators": [] }, @@ -2344,9 +2354,9 @@ }, "Location": "Path", "DefaultValue": { - "$id": "285", + "$id": "287", "Type": { - "$ref": "283" + "$ref": "285" }, "Value": 123 }, @@ -2360,14 +2370,14 @@ "Kind": "Constant" }, { - "$id": "286", + "$id": "288", "Name": "p3", "NameInRequest": "p3", "Type": { - "$id": "287", + "$id": "289", "Kind": "constant", "ValueType": { - "$id": "288", + "$id": "290", "Kind": "boolean", "Decorators": [] }, @@ -2376,9 +2386,9 @@ }, "Location": "Query", "DefaultValue": { - "$id": "289", + "$id": "291", "Type": { - "$ref": "287" + "$ref": "289" }, "Value": true }, @@ -2392,11 +2402,11 @@ "Kind": "Constant" }, { - "$id": "290", + "$id": "292", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "291", + "$id": "293", "Kind": "string" }, "Location": "Header", @@ -2409,9 +2419,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "292", + "$id": "294", "Type": { - "$ref": "291" + "$ref": "293" }, "Value": "application/json" } @@ -2419,7 +2429,7 @@ ], "Responses": [ { - "$id": "293", + "$id": "295", "StatusCodes": [ 200 ], @@ -2443,25 +2453,25 @@ "GenerateConvenienceMethod": true }, { - "$id": "294", + "$id": "296", "Name": "topAction", "ResourceName": "UnbrandedTypeSpec", "Description": "top level method", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "295", + "$id": "297", "Name": "action", "NameInRequest": "action", "Type": { - "$id": "296", + "$id": "298", "Kind": "utcDateTime", "Encode": "rfc3339", "WireType": { - "$id": "297", + "$id": "299", "Kind": "string", "Decorators": [] }, @@ -2478,11 +2488,11 @@ "Kind": "Method" }, { - "$id": "298", + "$id": "300", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "299", + "$id": "301", "Kind": "string" }, "Location": "Header", @@ -2495,9 +2505,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "300", + "$id": "302", "Type": { - "$ref": "299" + "$ref": "301" }, "Value": "application/json" } @@ -2505,7 +2515,7 @@ ], "Responses": [ { - "$id": "301", + "$id": "303", "StatusCodes": [ 200 ], @@ -2529,21 +2539,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "302", + "$id": "304", "Name": "topAction2", "ResourceName": "UnbrandedTypeSpec", "Description": "top level method2", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "303", + "$id": "305", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "304", + "$id": "306", "Kind": "string" }, "Location": "Header", @@ -2556,9 +2566,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "305", + "$id": "307", "Type": { - "$ref": "304" + "$ref": "306" }, "Value": "application/json" } @@ -2566,7 +2576,7 @@ ], "Responses": [ { - "$id": "306", + "$id": "308", "StatusCodes": [ 200 ], @@ -2590,17 +2600,17 @@ "GenerateConvenienceMethod": false }, { - "$id": "307", + "$id": "309", "Name": "patchAction", "ResourceName": "UnbrandedTypeSpec", "Description": "top level patch", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "308", + "$id": "310", "Name": "body", "NameInRequest": "body", "Type": { @@ -2617,11 +2627,11 @@ "Kind": "Method" }, { - "$id": "309", + "$id": "311", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "310", + "$id": "312", "Kind": "string" }, "Location": "Header", @@ -2634,19 +2644,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "311", + "$id": "313", "Type": { - "$ref": "310" + "$ref": "312" }, "Value": "application/json" } }, { - "$id": "312", + "$id": "314", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "313", + "$id": "315", "Kind": "string" }, "Location": "Header", @@ -2659,9 +2669,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "314", + "$id": "316", "Type": { - "$ref": "313" + "$ref": "315" }, "Value": "application/json" } @@ -2669,7 +2679,7 @@ ], "Responses": [ { - "$id": "315", + "$id": "317", "StatusCodes": [ 200 ], @@ -2696,17 +2706,17 @@ "GenerateConvenienceMethod": false }, { - "$id": "316", + "$id": "318", "Name": "anonymousBody", "ResourceName": "UnbrandedTypeSpec", "Description": "body parameter without body decorator", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "317", + "$id": "319", "Name": "Thing", "NameInRequest": "Thing", "Description": "A model with a few properties of literal types", @@ -2724,11 +2734,11 @@ "Kind": "Spread" }, { - "$id": "318", + "$id": "320", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "319", + "$id": "321", "Kind": "string" }, "Location": "Header", @@ -2741,19 +2751,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "320", + "$id": "322", "Type": { - "$ref": "319" + "$ref": "321" }, "Value": "application/json" } }, { - "$id": "321", + "$id": "323", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "322", + "$id": "324", "Kind": "string" }, "Location": "Header", @@ -2766,9 +2776,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "323", + "$id": "325", "Type": { - "$ref": "322" + "$ref": "324" }, "Value": "application/json" } @@ -2776,7 +2786,7 @@ ], "Responses": [ { - "$id": "324", + "$id": "326", "StatusCodes": [ 200 ], @@ -2803,17 +2813,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "325", + "$id": "327", "Name": "friendlyModel", "ResourceName": "UnbrandedTypeSpec", "Description": "Model can have its friendly name", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "326", + "$id": "328", "Name": "Friend", "NameInRequest": "NotFriend", "Description": "this is not a friendly model but with a friendly name", @@ -2831,11 +2841,11 @@ "Kind": "Spread" }, { - "$id": "327", + "$id": "329", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "328", + "$id": "330", "Kind": "string" }, "Location": "Header", @@ -2848,19 +2858,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "329", + "$id": "331", "Type": { - "$ref": "328" + "$ref": "330" }, "Value": "application/json" } }, { - "$id": "330", + "$id": "332", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "331", + "$id": "333", "Kind": "string" }, "Location": "Header", @@ -2873,9 +2883,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "332", + "$id": "334", "Type": { - "$ref": "331" + "$ref": "333" }, "Value": "application/json" } @@ -2883,7 +2893,7 @@ ], "Responses": [ { - "$id": "333", + "$id": "335", "StatusCodes": [ 200 ], @@ -2910,24 +2920,24 @@ "GenerateConvenienceMethod": true }, { - "$id": "334", + "$id": "336", "Name": "addTimeHeader", "ResourceName": "UnbrandedTypeSpec", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "335", + "$id": "337", "Name": "repeatabilityFirstSent", "NameInRequest": "Repeatability-First-Sent", "Type": { - "$id": "336", + "$id": "338", "Kind": "utcDateTime", "Encode": "rfc7231", "WireType": { - "$id": "337", + "$id": "339", "Kind": "string", "Decorators": [] }, @@ -2944,11 +2954,11 @@ "Kind": "Method" }, { - "$id": "338", + "$id": "340", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "339", + "$id": "341", "Kind": "string" }, "Location": "Header", @@ -2961,9 +2971,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "340", + "$id": "342", "Type": { - "$ref": "339" + "$ref": "341" }, "Value": "application/json" } @@ -2971,7 +2981,7 @@ ], "Responses": [ { - "$id": "341", + "$id": "343", "StatusCodes": [ 204 ], @@ -2986,20 +2996,20 @@ "Path": "/", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": false + "GenerateConvenienceMethod": true }, { - "$id": "342", + "$id": "344", "Name": "projectedNameModel", "ResourceName": "UnbrandedTypeSpec", "Description": "Model can have its projected name", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "343", + "$id": "345", "Name": "ProjectedModel", "NameInRequest": "ModelWithProjectedName", "Description": "this is a model with a projected name", @@ -3017,11 +3027,11 @@ "Kind": "Spread" }, { - "$id": "344", + "$id": "346", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "345", + "$id": "347", "Kind": "string" }, "Location": "Header", @@ -3034,19 +3044,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "346", + "$id": "348", "Type": { - "$ref": "345" + "$ref": "347" }, "Value": "application/json" } }, { - "$id": "347", + "$id": "349", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "348", + "$id": "350", "Kind": "string" }, "Location": "Header", @@ -3059,9 +3069,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "349", + "$id": "351", "Type": { - "$ref": "348" + "$ref": "350" }, "Value": "application/json" } @@ -3069,7 +3079,7 @@ ], "Responses": [ { - "$id": "350", + "$id": "352", "StatusCodes": [ 200 ], @@ -3096,21 +3106,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "351", + "$id": "353", "Name": "returnsAnonymousModel", "ResourceName": "UnbrandedTypeSpec", "Description": "return anonymous model", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "352", + "$id": "354", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "353", + "$id": "355", "Kind": "string" }, "Location": "Header", @@ -3123,9 +3133,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "354", + "$id": "356", "Type": { - "$ref": "353" + "$ref": "355" }, "Value": "application/json" } @@ -3133,12 +3143,12 @@ ], "Responses": [ { - "$id": "355", + "$id": "357", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "178" + "$ref": "180" }, "BodyMediaType": "Json", "Headers": [], @@ -3157,21 +3167,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "356", + "$id": "358", "Name": "getUnknownValue", "ResourceName": "UnbrandedTypeSpec", "Description": "get extensible enum", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "357", + "$id": "359", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "358", + "$id": "360", "Kind": "string" }, "Location": "Header", @@ -3184,9 +3194,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "359", + "$id": "361", "Type": { - "$ref": "358" + "$ref": "360" }, "Value": "application/json" } @@ -3194,12 +3204,12 @@ ], "Responses": [ { - "$id": "360", + "$id": "362", "StatusCodes": [ 200 ], "BodyType": { - "$id": "361", + "$id": "363", "Kind": "string", "Decorators": [] }, @@ -3217,20 +3227,20 @@ "Path": "/unknown-value", "BufferResponse": true, "GenerateProtocolMethod": true, - "GenerateConvenienceMethod": false + "GenerateConvenienceMethod": true }, { - "$id": "362", + "$id": "364", "Name": "internalProtocol", "ResourceName": "UnbrandedTypeSpec", "Description": "When set protocol false and convenient true, then the protocol method should be internal", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "363", + "$id": "365", "Name": "body", "NameInRequest": "body", "Type": { @@ -3247,11 +3257,11 @@ "Kind": "Method" }, { - "$id": "364", + "$id": "366", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "365", + "$id": "367", "Kind": "string" }, "Location": "Header", @@ -3264,19 +3274,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "366", + "$id": "368", "Type": { - "$ref": "365" + "$ref": "367" }, "Value": "application/json" } }, { - "$id": "367", + "$id": "369", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "368", + "$id": "370", "Kind": "string" }, "Location": "Header", @@ -3289,9 +3299,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "369", + "$id": "371", "Type": { - "$ref": "368" + "$ref": "370" }, "Value": "application/json" } @@ -3299,7 +3309,7 @@ ], "Responses": [ { - "$id": "370", + "$id": "372", "StatusCodes": [ 200 ], @@ -3326,21 +3336,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "371", + "$id": "373", "Name": "stillConvenient", "ResourceName": "UnbrandedTypeSpec", "Description": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "372", + "$id": "374", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "373", + "$id": "375", "Kind": "string" }, "Location": "Header", @@ -3353,9 +3363,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "374", + "$id": "376", "Type": { - "$ref": "373" + "$ref": "375" }, "Value": "application/json" } @@ -3363,7 +3373,7 @@ ], "Responses": [ { - "$id": "375", + "$id": "377", "StatusCodes": [ 204 ], @@ -3381,21 +3391,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "376", + "$id": "378", "Name": "headAsBoolean", "ResourceName": "UnbrandedTypeSpec", "Description": "head as boolean.", "Accessibility": "public", "Parameters": [ { - "$ref": "224" + "$ref": "226" }, { - "$id": "377", + "$id": "379", "Name": "id", "NameInRequest": "id", "Type": { - "$id": "378", + "$id": "380", "Kind": "string", "Decorators": [] }, @@ -3410,11 +3420,11 @@ "Kind": "Method" }, { - "$id": "379", + "$id": "381", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "380", + "$id": "382", "Kind": "string" }, "Location": "Header", @@ -3427,9 +3437,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "381", + "$id": "383", "Type": { - "$ref": "380" + "$ref": "382" }, "Value": "application/json" } @@ -3437,7 +3447,7 @@ ], "Responses": [ { - "$id": "382", + "$id": "384", "StatusCodes": [ 204 ], @@ -3456,20 +3466,20 @@ } ], "Protocol": { - "$id": "383" + "$id": "385" }, "Parameters": [ { - "$ref": "224" + "$ref": "226" } ], "Decorators": [] } ], "Auth": { - "$id": "384", + "$id": "386", "ApiKey": { - "$id": "385", + "$id": "387", "Name": "my-api-key" } } From 301151c93d80d3fa32c562c6ee061b5bcd458f03 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 19 Jul 2024 16:27:31 +0800 Subject: [PATCH 04/26] remove predefined decorator list --- .../emitter/src/constants.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/http-client-csharp/emitter/src/constants.ts b/packages/http-client-csharp/emitter/src/constants.ts index 6941ce64fa6..be7ee858391 100644 --- a/packages/http-client-csharp/emitter/src/constants.ts +++ b/packages/http-client-csharp/emitter/src/constants.ts @@ -1,22 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +import { CreateSdkContextOptions } from "@azure-tools/typespec-client-generator-core"; + export const projectedNameJsonKey = "json"; export const projectedNameCSharpKey = "csharp"; export const projectedNameClientKey = "client"; export const mockApiVersion = "0000-00-00"; export const tspOutputFileName = "tspCodeModel.json"; export const configurationFileName = "Configuration.json"; -export let createSDKContextoptions = { - additionalDecorators: ["TypeSpec\\.@projectedName"], -}; -export function getSDKContextOptions(): any { +export let createSDKContextoptions: CreateSdkContextOptions = {}; +export function getSDKContextOptions(): CreateSdkContextOptions { return createSDKContextoptions; } -export function setSDKContextOptions(options: any): void { +export function setSDKContextOptions(options: CreateSdkContextOptions): void { createSDKContextoptions = options; } export function addAdditionalDecorators(additionalDecorators: string[]): void { - createSDKContextoptions.additionalDecorators = - createSDKContextoptions.additionalDecorators.concat(additionalDecorators); + if (!createSDKContextoptions.additionalDecorators) { + createSDKContextoptions.additionalDecorators = additionalDecorators; + } else { + createSDKContextoptions.additionalDecorators = + createSDKContextoptions.additionalDecorators.concat(additionalDecorators); + } } From 8faa44cf037bf232694a846aad3ef9af6fa4ce5e Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 24 Jul 2024 14:59:27 +0800 Subject: [PATCH 05/26] add decorator list in inputModel --- .../emitter/test/Unit/model-type.test.ts | 3 +++ .../emitter/test/Unit/scalar.test.ts | 1 + .../emitter/test/Unit/string-format.test.ts | 2 ++ .../src/InputTypes/InputArrayType.cs | 5 ++++- .../src/InputTypes/InputDateTimeType.cs | 5 ++++- .../src/InputTypes/InputDecoratedType.cs | 20 +++++++++++++++++ .../src/InputTypes/InputDecoratorInfo.cs | 22 +++++++++++++++++++ .../src/InputTypes/InputDictionaryType.cs | 5 ++++- .../src/InputTypes/InputDurationType.cs | 5 ++++- .../src/InputTypes/InputEnumType.cs | 5 +++-- .../src/InputTypes/InputLiteralType.cs | 5 ++++- .../src/InputTypes/InputModelProperty.cs | 5 +++-- .../src/InputTypes/InputModelType.cs | 5 +++-- .../src/InputTypes/InputNullableType.cs | 4 +++- .../src/InputTypes/InputPrimitiveType.cs | 15 +++++++++++-- .../src/InputTypes/InputType.cs | 14 +++++++----- .../TypeSpecInputArrayTypeConverter.cs | 8 +++++-- .../TypeSpecInputNullableTypeConverter.cs | 8 +++++-- 18 files changed, 114 insertions(+), 23 deletions(-) create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs diff --git a/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts b/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts index 978bb23e1e3..408ae18f911 100644 --- a/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts @@ -74,6 +74,7 @@ op test(@body input: Pet): Pet; IsDiscriminator: true, Description: "Discriminator property for Pet.", FlattenedNames: undefined, + Decorators: [], } as InputModelProperty, discriminatorProperty ); @@ -185,6 +186,7 @@ op test(@body input: Pet): Pet; IsReadOnly: false, IsDiscriminator: true, FlattenedNames: undefined, + Decorators: [], } as InputModelProperty, discriminatorProperty ); @@ -306,6 +308,7 @@ op test(@body input: Pet): Pet; IsReadOnly: false, IsDiscriminator: true, FlattenedNames: undefined, + Decorators: [], } as InputModelProperty, discriminatorProperty ); diff --git a/packages/http-client-csharp/emitter/test/Unit/scalar.test.ts b/packages/http-client-csharp/emitter/test/Unit/scalar.test.ts index ccbdfbd6673..6823e6bf43a 100644 --- a/packages/http-client-csharp/emitter/test/Unit/scalar.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/scalar.test.ts @@ -33,6 +33,7 @@ describe("Test GetInputType for scalar", () => { { Kind: "azureLocation", Encode: "string", + Decorators: [], }, root.Clients[0].Operations[0].Parameters[0].Type ); diff --git a/packages/http-client-csharp/emitter/test/Unit/string-format.test.ts b/packages/http-client-csharp/emitter/test/Unit/string-format.test.ts index a31cd0d4fff..3de0e131f72 100644 --- a/packages/http-client-csharp/emitter/test/Unit/string-format.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/string-format.test.ts @@ -44,6 +44,7 @@ describe("Test string format", () => { { Kind: "url", Encode: undefined, + Decorators: [], } as InputPrimitiveType, operation.Parameters[0].Type ); @@ -72,6 +73,7 @@ describe("Test string format", () => { { Kind: "url", Encode: undefined, + Decorators: [], } as InputPrimitiveType, foo.Properties[0].Type ); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs index 1491d0cf475..2b64f9328f3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs @@ -1,6 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { /// @@ -12,7 +15,7 @@ public sealed class InputArrayType : InputType /// The name of the list type. /// The crossLanguageDefinitionId of the list type. For a builtin array, it should be `TypeSpec.Array`. /// The element's . - public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType) : base(name) + public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType, IReadOnlyList decorators) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs index f4b7bbc394b..42463718870 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public class InputDateTimeType : InputType { - public InputDateTimeType(DateTimeKnownEncoding encode, InputPrimitiveType wireType) : base("DateTime") + public InputDateTimeType(DateTimeKnownEncoding encode, InputPrimitiveType wireType, IReadOnlyList decorators) : base("DateTime", decorators) { Encode = encode; WireType = wireType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs new file mode 100644 index 00000000000..06ffb833dd1 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Generator.CSharp.Input.InputTypes +{ + public class InputDecoratedType + { + public InputDecoratedType(IReadOnlyList decorators) + { + Decorators = decorators; + } + public IReadOnlyList Decorators { get; } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs new file mode 100644 index 00000000000..89835aec748 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Generator.CSharp.Input.InputTypes +{ + public class InputDecoratorInfo + { + public InputDecoratorInfo(string name, IReadOnlyDictionary arguments) + { + Name = name; + Arguments = arguments; + } + public string Name { get; } + public IReadOnlyDictionary Arguments { get; } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs index c2b88a1fcd7..0fdb439039d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs @@ -1,6 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { /// @@ -13,7 +16,7 @@ public sealed class InputDictionaryType : InputType /// The key's . /// The value's . /// Flag used to determine if the input dictionary type is nullable. - public InputDictionaryType(string name, InputType keyType, InputType valueType) : base(name) + public InputDictionaryType(string name, InputType keyType, InputType valueType, IReadOnlyList decorators) : base(name, decorators) { KeyType = keyType; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs index b785cfe6f5e..303b81e4601 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public class InputDurationType : InputType { - public InputDurationType(DurationKnownEncoding encode, InputPrimitiveType wireType) : base("Duration") + public InputDurationType(DurationKnownEncoding encode, InputPrimitiveType wireType, IReadOnlyList decorators) : base("Duration", decorators) { Encode = encode; WireType = wireType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs index dde598de30e..f707902b675 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs @@ -2,13 +2,14 @@ // Licensed under the MIT License. using System.Collections.Generic; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { public class InputEnumType : InputType { - public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible) - : base(name) + public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible, IReadOnlyList decorators) + : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Accessibility = accessibility; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs index 7db00875d86..9c1613e5c1f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public sealed class InputLiteralType : InputType { - public InputLiteralType(InputType valueType, object value) : base("Literal") + public InputLiteralType(InputType valueType, object value, IReadOnlyList decorators) : base("Literal", decorators) { ValueType = valueType; Value = value; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 32891685f96..fa688268407 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -3,12 +3,13 @@ using System; using System.Collections.Generic; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { - public class InputModelProperty + public class InputModelProperty: InputDecoratedType { - public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList? flattenedNames = null) + public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null): base(decorators) { Name = name; SerializedName = serializedName; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index ae0753a8337..290279f036e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -11,8 +12,8 @@ namespace Microsoft.Generator.CSharp.Input public class InputModelType : InputType { // TODO: Follow up issue https://github.com/microsoft/typespec/issues/3619. After https://github.com/Azure/typespec-azure/pull/966 is completed, update this type and remove the "modelAsStruct" parameter. - public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct) - : base(name) + public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct, IReadOnlyList decorators) + : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Access = access; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index c8c03875019..f5ede8723f1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -1,13 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { public sealed class InputNullableType : InputType { - public InputNullableType(InputType type) : base("nullable") + public InputNullableType(InputType type, IReadOnlyList decorators) : base("nullable", decorators) { Type = type; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs index c38562e5e6f..d9c054bbb3a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs @@ -1,16 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.Generator.CSharp.Input.InputTypes; +using System; +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public sealed class InputPrimitiveType : InputType { - public InputPrimitiveType(InputPrimitiveTypeKind kind) : base(kind.ToString()) + public InputPrimitiveType(InputPrimitiveTypeKind kind) : this(kind, Array.Empty()) + { + } + public InputPrimitiveType(InputPrimitiveTypeKind kind, IReadOnlyList decorators) : base(kind.ToString(), decorators) { Kind = kind; } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string? encode, bool isNullable = false) : this(kind) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string? encode, bool isNullable = false) : this(kind, Array.Empty(), encode, isNullable) + { + } + + public InputPrimitiveType(InputPrimitiveTypeKind kind, IReadOnlyList decorators, string? encode, bool isNullable = false) : this(kind, decorators) { Encode = encode; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index aeec347504b..d0f07b574d5 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -1,20 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; using AutoRest.CSharp.Common.Input.InputTypes; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { /// /// Represents an input type to the generator. /// - public abstract class InputType + public abstract class InputType: InputDecoratedType { /// /// Construct a new instance /// /// The name of the input type. - protected InputType(string name) + protected InputType(string name, IReadOnlyList decorators): base(decorators) { Name = name; } @@ -29,12 +31,14 @@ internal InputType GetCollectionEquivalent(InputType inputType) return new InputArrayType( listType.Name, listType.CrossLanguageDefinitionId, - listType.ValueType.GetCollectionEquivalent(inputType)); + listType.ValueType.GetCollectionEquivalent(inputType), + listType.Decorators); case InputDictionaryType dictionaryType: return new InputDictionaryType( dictionaryType.Name, dictionaryType.KeyType, - dictionaryType.ValueType.GetCollectionEquivalent(inputType)); + dictionaryType.ValueType.GetCollectionEquivalent(inputType), + dictionaryType.Decorators); default: return inputType; } @@ -42,7 +46,7 @@ internal InputType GetCollectionEquivalent(InputType inputType) public InputType WithNullable(bool isNullable) { if (isNullable) - return new InputNullableType(this); + return new InputNullableType(this, this.Decorators); return this; } public InputType GetImplementType() => this switch diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs index 85cc57c09ac..011c6d44ff3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -27,12 +29,14 @@ public static InputArrayType CreateListType(ref Utf8JsonReader reader, string? i var isFirstProperty = id == null; string? crossLanguageDefinitionId = null; InputType? valueType = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputArrayType.Name), ref name) || reader.TryReadString(nameof(InputArrayType.CrossLanguageDefinitionId), ref crossLanguageDefinitionId) - || reader.TryReadWithConverter(nameof(InputArrayType.ValueType), options, ref valueType); + || reader.TryReadWithConverter(nameof(InputArrayType.ValueType), options, ref valueType) + || reader.TryReadWithConverter(nameof(InputArrayType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -41,7 +45,7 @@ public static InputArrayType CreateListType(ref Utf8JsonReader reader, string? i } valueType = valueType ?? throw new JsonException("List must have element type"); - var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType); + var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType, decorators ?? Array.Empty()); if (id != null) { resolver.AddReference(id, listType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 786e8265ae8..9c3d867ac1f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -2,9 +2,11 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace AutoRest.CSharp.Common.Input.InputTypes.Serialization { @@ -26,11 +28,13 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st { var isFirstProperty = id == null && name == null; InputType? valueType = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputNullableType.Name), ref name) - || reader.TryReadWithConverter(nameof(InputNullableType.Type), options, ref valueType); + || reader.TryReadWithConverter(nameof(InputNullableType.Type), options, ref valueType) + || reader.TryReadWithConverter(nameof(InputNullableType.Type), options, ref decorators); if (!isKnownProperty) { @@ -40,7 +44,7 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st valueType = valueType ?? throw new JsonException("InputNullableType must have value type"); - var nullableType = new InputNullableType(valueType); + var nullableType = new InputNullableType(valueType, decorators ?? Array.Empty()); if (id != null) { resolver.AddReference(id, nullableType); From 40cc2dac87292215ff08e643c95129c1b4b9e307 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 24 Jul 2024 17:07:45 +0800 Subject: [PATCH 06/26] update test --- .../JsonModelCoreTests.cs | 34 +- .../MrwSerializationConstructorTests.cs | 13 +- .../MrwSerializationTypeDefinitionTests.cs | 51 +- .../PersistableModelCoreTests.cs | 6 +- .../src/InputTypes/InputDecoratedType.cs | 6 +- .../src/InputTypes/InputDecoratorInfo.cs | 4 - .../src/InputTypes/InputModelProperty.cs | 4 +- .../src/InputTypes/InputModelType.cs | 1 - .../src/InputTypes/InputNullableType.cs | 1 - .../src/InputTypes/InputType.cs | 5 +- .../src/InputTypes/InputUnionType.cs | 3 +- .../TypeSpecInputDateTimeTypeConverter.cs | 8 +- .../TypeSpecInputDictionaryTypeConverter.cs | 8 +- .../TypeSpecInputDurationTypeConverter.cs | 8 +- .../TypeSpecInputEnumTypeConverter.cs | 7 +- .../TypeSpecInputLiteralTypeConverter.cs | 8 +- .../TypeSpecInputModelPropertyConverter.cs | 5 +- .../TypeSpecInputModelTypeConverter.cs | 9 +- .../TypeSpecInputUnionTypeConverter.cs | 3 +- .../perf/CodeWriterBenchmark.cs | 5 +- .../Expressions/NewInstanceExpressionTests.cs | 4 +- .../test/Providers/EnumProviderTests.cs | 14 +- .../test/Providers/ModelProviderTests.cs | 53 +- .../Providers/PropertyDescriptionTests.cs | 13 +- .../test/Providers/PropertyProviderTests.cs | 34 +- .../test/TypeFactoryTests.cs | 19 +- .../test/Writers/TypeProviderWriterTests.cs | 13 +- .../Unbranded-TypeSpec/tspCodeModel.json | 528 +++++++++--------- 28 files changed, 456 insertions(+), 411 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index 6bee1c1c1c8..57234148597 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -42,10 +44,11 @@ public void KebabCaseSerializedName() "kebab-case", "kebab-case", "A property with kebab-case name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -60,7 +63,8 @@ public void KebabCaseSerializedName() null, new Dictionary(), null, - false); + false, + Array.Empty()); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -75,10 +79,11 @@ public void SnakeCaseSerializedName() "snake_case", "snake_case", "A property with snake_case name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -93,7 +98,8 @@ public void SnakeCaseSerializedName() null, new Dictionary(), null, - false); + false, + Array.Empty()); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -108,10 +114,11 @@ public void PascalCaseSerializedName() "PascalCase", "PascalCase", "A property with PascalCase name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -126,7 +133,8 @@ public void PascalCaseSerializedName() null, new Dictionary(), null, - false); + false, + Array.Empty()); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -141,10 +149,11 @@ public void CamelCaseSerializedName() "camelCase", "camelCase", "A property with camelCase name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -159,7 +168,8 @@ public void CamelCaseSerializedName() null, new Dictionary(), null, - false); + false, + Array.Empty()); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs index 3dc1fa42d35..ded8b6cb451 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -36,16 +37,16 @@ public void TestBuildConstructors() { var baseProperties = new List { - new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false), - new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false), + new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), }; var derivedProperties = new List { - new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false), - new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false), + new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), }; - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index c6d70711ff6..9e9775710d3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -11,6 +11,7 @@ using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -39,7 +40,7 @@ internal static (TypeProvider Model, MrwSerializationTypeDefinition Serializatio public void TestBuildImplements() { // mock the model type provider - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var interfaces = serialization.Implements; @@ -56,7 +57,7 @@ public void TestBuildImplements() [Test] public void TestBuildJsonModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteCoreMethod(); @@ -91,7 +92,7 @@ public void TestBuildJsonModelWriteCoreMethod() [Test] public void TestBuildJsonModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteMethodObjectDeclaration(); @@ -125,7 +126,7 @@ public void TestBuildJsonModelWriteMethodObjectDeclaration() [Test] public void TestBuildJsonModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethod(); @@ -145,7 +146,7 @@ public void TestBuildJsonModelCreateMethod() [Test] public void TestBuildJsonModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateCoreMethod(); @@ -180,7 +181,7 @@ public void TestBuildJsonModelCreateCoreMethod() [Test] public void TestBuildJsonModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethodObjectDeclaration(); @@ -215,7 +216,7 @@ public void TestBuildJsonModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelWriteMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethod(); @@ -235,7 +236,7 @@ public void TestBuildPersistableModelWriteMethod() [Test] public void TestBuildPersistableModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteCoreMethod(); @@ -270,7 +271,7 @@ public void TestBuildPersistableModelWriteCoreMethod() [Test] public void TestBuildPersistableModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethodObjectDeclaration(); @@ -304,7 +305,7 @@ public void TestBuildPersistableModelWriteMethodObjectDeclaration() [Test] public void TestBuildPersistableModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -334,7 +335,7 @@ public void TestBuildPersistableModelCreateMethod() [Test] public void TestBuildPersistableModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); Assert.IsNotNull(serialization); @@ -363,7 +364,7 @@ public void TestBuildPersistableModelCreateCoreMethod() [Test] public void BuildPersistableModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethodObjectDeclaration(); @@ -397,7 +398,7 @@ public void BuildPersistableModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -417,7 +418,7 @@ public void TestBuildPersistableModelDeserializationMethod() [Test] public void TestBuildPersistableModelGetFormatMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsMethod(); @@ -440,7 +441,7 @@ public void TestBuildPersistableModelGetFormatMethod() [Test] public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsObjectDeclaration(); @@ -473,7 +474,7 @@ public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() [Test] public void TestBuildSerializationConstructor() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var constructor = serialization.BuildSerializationConstructor(); @@ -490,7 +491,7 @@ public void TestBuildSerializationConstructor() [Test] public void TestBuildFields() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var fields = serialization.Fields; @@ -508,13 +509,13 @@ public void TestBuildConstructor_ValidateConstructors() { var properties = new List { - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), - new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), true, false, false), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String)), true, false, false), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), + new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), true, false, false, Array.Empty()), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), true, false, false, Array.Empty()), }; - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var ctors = serialization.Constructors; @@ -534,7 +535,7 @@ public void TestBuildConstructor_ValidateConstructors() [Test] public void TestBuildDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var deserializationMethod = serialization.BuildDeserializationMethod(); @@ -556,7 +557,7 @@ public void TestBuildDeserializationMethod() [Test] public void TestBuildImplicitToBinaryContent() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; @@ -584,7 +585,7 @@ public void TestBuildImplicitToBinaryContent() [Test] public void TestBuildExplicitFromClientResult() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs index f4220ecdf8e..03e94c7f90d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -38,9 +40,9 @@ protected override MethodProvider[] BuildMethods() [Test] public void TestBuildPersistableModelCreateCoreMethod_DerivedType() { - var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, [], null, new List(), null, null, new Dictionary(), null, false); + var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, [], null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var inputDerived = new InputModelType("mockDerivedModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, - [], inputBase, new List(), null, null, new Dictionary(), null, false); + [], inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); var (derivedModel, derivedSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputDerived); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs index 06ffb833dd1..b4764d2654a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs @@ -1,11 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Generator.CSharp.Input.InputTypes { @@ -15,6 +11,6 @@ public InputDecoratedType(IReadOnlyList decorators) { Decorators = decorators; } - public IReadOnlyList Decorators { get; } + public IReadOnlyList Decorators { get; internal set; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs index 89835aec748..54b6199487c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs @@ -1,11 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Generator.CSharp.Input.InputTypes { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index fa688268407..0f56f3797ba 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -7,9 +7,9 @@ namespace Microsoft.Generator.CSharp.Input { - public class InputModelProperty: InputDecoratedType + public class InputModelProperty : InputDecoratedType { - public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null): base(decorators) + public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null) : base(decorators) { Name = name; SerializedName = serializedName; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index 290279f036e..e56593348b0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index f5ede8723f1..6d33134d6d3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index d0f07b574d5..e85c4415009 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using AutoRest.CSharp.Common.Input.InputTypes; using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input @@ -10,13 +9,13 @@ namespace Microsoft.Generator.CSharp.Input /// /// Represents an input type to the generator. /// - public abstract class InputType: InputDecoratedType + public abstract class InputType : InputDecoratedType { /// /// Construct a new instance /// /// The name of the input type. - protected InputType(string name, IReadOnlyList decorators): base(decorators) + protected InputType(string name, IReadOnlyList decorators) : base(decorators) { Name = name; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs index d66a2c0d8c4..98db71c9986 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs @@ -2,12 +2,13 @@ // Licensed under the MIT License. using System.Collections.Generic; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { public class InputUnionType : InputType { - public InputUnionType(string name, IReadOnlyList variantTypes) : base(name) + public InputUnionType(string name, IReadOnlyList variantTypes, IReadOnlyList decorators) : base(name, decorators) { VariantTypes = variantTypes; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs index 6868e37cd51..eee9f04c006 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -26,12 +28,14 @@ public static InputDateTimeType CreateDateTimeType(ref Utf8JsonReader reader, st var isFirstProperty = id == null; string? encode = null; InputType? type = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputDateTimeType.Encode), ref encode) - || reader.TryReadWithConverter(nameof(InputDateTimeType.WireType), options, ref type); + || reader.TryReadWithConverter(nameof(InputDateTimeType.WireType), options, ref type) + || reader.TryReadWithConverter(nameof(InputDateTimeType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -47,7 +51,7 @@ public static InputDateTimeType CreateDateTimeType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("DateTime type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDateTimeType(encodeKind, wireType) + ? new InputDateTimeType(encodeKind, wireType, decorators ?? Array.Empty()) : throw new JsonException($"Encoding of DateTime type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs index 6838d0b645d..6e54cdeee43 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -27,11 +29,13 @@ public static InputDictionaryType CreateDictionaryType(ref Utf8JsonReader reader var isFirstProperty = id == null; InputType? keyType = null; InputType? valueType = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadWithConverter(nameof(InputDictionaryType.KeyType), options, ref keyType) - || reader.TryReadWithConverter(nameof(InputDictionaryType.ValueType), options, ref valueType); + || reader.TryReadWithConverter(nameof(InputDictionaryType.ValueType), options, ref valueType) + || reader.TryReadWithConverter(nameof(InputDictionaryType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -42,7 +46,7 @@ public static InputDictionaryType CreateDictionaryType(ref Utf8JsonReader reader keyType = keyType ?? throw new JsonException("Dictionary must have key type"); valueType = valueType ?? throw new JsonException("Dictionary must have value type"); - var dictType = new InputDictionaryType("Dictionary", keyType, valueType); + var dictType = new InputDictionaryType("Dictionary", keyType, valueType, decorators ?? Array.Empty()); if (id != null) { resolver.AddReference(id, dictType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs index bc7664be3bf..6f766cff4ff 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -26,12 +28,14 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st var isFirstProperty = id == null; string? encode = null; InputType? type = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputDurationType.Encode), ref encode) - || reader.TryReadWithConverter(nameof(InputDurationType.WireType), options, ref type); + || reader.TryReadWithConverter(nameof(InputDurationType.WireType), options, ref type) + || reader.TryReadWithConverter(nameof(InputDurationType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -47,7 +51,7 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("Duration type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDurationType(encodeKind, wireType) + ? new InputDurationType(encodeKind, wireType, decorators ?? Array.Empty()) : throw new JsonException($"Encoding of Duration type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs index 4896f91d5f0..62581029571 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -35,6 +36,7 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id bool isExtendable = false; InputType? valueType = null; IReadOnlyList? values = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) @@ -46,7 +48,8 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id || reader.TryReadString(nameof(InputEnumType.Usage), ref usageString) || reader.TryReadBoolean(nameof(InputEnumType.IsExtensible), ref isExtendable) || reader.TryReadWithConverter(nameof(InputEnumType.ValueType), options, ref valueType) - || reader.TryReadWithConverter(nameof(InputEnumType.Values), options, ref values); + || reader.TryReadWithConverter(nameof(InputEnumType.Values), options, ref values) + || reader.TryReadWithConverter(nameof(InputEnumType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -76,7 +79,7 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id throw new JsonException("The ValueType of an EnumType must be a primitive type."); } - var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable); + var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable, decorators ?? Array.Empty()); if (id != null) { resolver.AddReference(id, enumType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs index 9f866fecc7e..b555e4c7a13 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -26,11 +28,13 @@ public static InputLiteralType CreateInputLiteralType(ref Utf8JsonReader reader, var isFirstProperty = id == null && name == null; object? value = null; InputType? type = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) - || reader.TryReadWithConverter(nameof(InputLiteralType.ValueType), options, ref type); + || reader.TryReadWithConverter(nameof(InputLiteralType.ValueType), options, ref type) + || reader.TryReadWithConverter(nameof(InputLiteralType.Decorators), options, ref decorators); if (isKnownProperty) { @@ -51,7 +55,7 @@ public static InputLiteralType CreateInputLiteralType(ref Utf8JsonReader reader, value = value ?? throw new JsonException("InputConstant must have value"); - var literalType = new InputLiteralType(type, value); + var literalType = new InputLiteralType(type, value, decorators ?? Array.Empty()); if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index 6798277326f..a32b02f6ea1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -32,6 +33,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read bool isReadOnly = false; bool isRequired = false; bool isDiscriminator = false; + IReadOnlyList? decorators = null; IReadOnlyList? flattenedNames = null; while (reader.TokenType != JsonTokenType.EndObject) @@ -44,6 +46,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read || reader.TryReadBoolean(nameof(InputModelProperty.IsReadOnly), ref isReadOnly) || reader.TryReadBoolean(nameof(InputModelProperty.IsRequired), ref isRequired) || reader.TryReadBoolean(nameof(InputModelProperty.IsDiscriminator), ref isDiscriminator) + || reader.TryReadWithConverter(nameof(InputModelProperty.Decorators), options, ref decorators) || reader.TryReadWithConverter(nameof(InputModelProperty.FlattenedNames), options, ref flattenedNames); if (!isKnownProperty) @@ -58,7 +61,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read // description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames); + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, decorators ?? Array.Empty(), flattenedNames); if (id != null) { resolver.AddReference(id, property); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs index cf05c0b0f6d..eb0fca21633 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -47,7 +48,8 @@ public static InputModelType CreateModelType(ref Utf8JsonReader reader, string? discriminatorProperty: null, discriminatedSubtypes: null!, additionalProperties: null, - modelAsStruct: false); + modelAsStruct: false, + decorators: Array.Empty()); resolver.AddReference(id, model); string? crossLanguageDefinitionId = null; @@ -61,6 +63,7 @@ public static InputModelType CreateModelType(ref Utf8JsonReader reader, string? InputModelType? baseModel = null; IReadOnlyList? properties = null; IReadOnlyDictionary? discriminatedSubtypes = null; + IReadOnlyList? decorators = null; bool modelAsStruct = false; // read all possible properties and throw away the unknown properties @@ -78,7 +81,8 @@ public static InputModelType CreateModelType(ref Utf8JsonReader reader, string? || reader.TryReadWithConverter(nameof(InputModelType.BaseModel), options, ref baseModel) || reader.TryReadWithConverter(nameof(InputModelType.Properties), options, ref properties) || reader.TryReadWithConverter(nameof(InputModelType.DiscriminatedSubtypes), options, ref discriminatedSubtypes) - || reader.TryReadBoolean(nameof(InputModelType.ModelAsStruct), ref modelAsStruct); + || reader.TryReadBoolean(nameof(InputModelType.ModelAsStruct), ref modelAsStruct) + || reader.TryReadWithConverter(nameof(InputModelType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -102,6 +106,7 @@ public static InputModelType CreateModelType(ref Utf8JsonReader reader, string? model.Properties = properties ?? Array.Empty(); model.DiscriminatedSubtypes = discriminatedSubtypes ?? new Dictionary(); model.ModelAsStruct = modelAsStruct; + model.Decorators = decorators ?? Array.Empty(); // if this model has a base, it means this model is a derived model of the base model, add it into the list. if (baseModel != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs index 3a12d56e1c3..b89f52522dc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { @@ -32,7 +33,7 @@ public static InputUnionType CreateInputUnionType(ref Utf8JsonReader reader, str id = id ?? throw new JsonException(); // create an empty model to resolve circular references - var union = new InputUnionType(null!, null!); + var union = new InputUnionType(null!, null!, Array.Empty()); resolver.AddReference(id, union); IReadOnlyList? variantTypes = null; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs index 96c2345e63c..0c47c4f93c4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using BenchmarkDotNet.Attributes; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; @@ -19,9 +20,9 @@ public CodeWriterBenchmark() PluginInitializer.Initialize(); var properties = new[] { - new InputModelProperty("MyProperty", "myProperty", "The property of mine", new InputPrimitiveType(InputPrimitiveTypeKind.Int32), true, false, false) + new InputModelProperty("MyProperty", "myProperty", "The property of mine", new InputPrimitiveType(InputPrimitiveTypeKind.Int32), true, false, false, Array.Empty()) }; - var inputModel = new InputModelType("MyModel", string.Empty, null, null, "Test model", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("MyModel", string.Empty, null, null, "Test model", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); var modelProvider = new ModelProvider(inputModel); _writer = new TypeProviderWriter(modelProvider); } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs index ff2e5264d11..f9b2e0e3df4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using NUnit.Framework; using static Microsoft.Generator.CSharp.Snippets.Snippet; @@ -44,7 +46,7 @@ public void ValidateAnonymousWithPropertiesSingleLine() [Test] public void ValidateNullableValueType() { - InputEnumType enumType = new InputEnumType("MyEnum", "MyEnum", "public", null, "MyEnum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "one", null), new InputEnumTypeValue("Two", "two", null)], true); + InputEnumType enumType = new InputEnumType("MyEnum", "MyEnum", "public", null, "MyEnum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "one", null), new InputEnumTypeValue("Two", "two", null)], true, Array.Empty()); var provider = CodeModelPlugin.Instance.TypeFactory.CreateEnum(enumType); var expr = New.Instance(provider.Type, Literal("three")); using CodeWriter writer = new CodeWriter(); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index ae8fd2afee4..8375b6bedff 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Linq; using System.Text; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using Microsoft.Generator.CSharp.Snippets; @@ -22,7 +24,7 @@ public void BuildEnumType_ValidateIntBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(int)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Int32), [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], false); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Int32), [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], false, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -63,7 +65,7 @@ public void BuildEnumType_ValidateFloatBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(float)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Float32), [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], false); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Float32), [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], false, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -101,7 +103,7 @@ public void BuildEnumType_ValidateStringBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], false); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], false, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -139,7 +141,7 @@ public void BuildEnumType_ValidateIntBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(int)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Int32), [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], true); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Int32), [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], true, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; @@ -196,7 +198,7 @@ public void BuildEnumType_ValidateFloatBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(float)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Float32), [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], true); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.Float32), [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], true, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; @@ -253,7 +255,7 @@ public void BuildEnumType_ValidateStringBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], true); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.RoundTrip, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], true, Array.Empty()); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs index 5bb644341b3..a35f2d5e5e2 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -24,7 +25,7 @@ public void BuildProperties_ValidatePropertySetters(InputModelProperty inputMode inputModelProperty }; - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, props, null, [], null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.RoundTrip, props, null, [], null, null, new Dictionary(), null, false, Array.Empty()); var modelTypeProvider = new ModelProvider(inputModel); var properties = modelTypeProvider.Properties; @@ -46,42 +47,42 @@ public static IEnumerable BuildProperties_ValidatePropertySettersT { // list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IList)), false); // read only list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, true, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, true, false, Array.Empty()), new CSharpType(typeof(IReadOnlyList)), false); // nullable list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IList), true), true); // dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IDictionary)), false); // nullable dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IDictionary), true), true); // primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, false, false, Array.Empty()), new CSharpType(typeof(string)), true); // read only primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, true, false), + new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, true, false, Array.Empty()), new CSharpType(typeof(string)), false); // readonlymemory property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(ReadOnlyMemory<>)), true); } @@ -105,11 +106,11 @@ public static IEnumerable BuildProperties_ValidatePropertySettersT public void BuildConstructor_ValidateConstructors() { var properties = new List{ - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), - new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), true, false, false), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String)), true, false, false), - new InputModelProperty("optionalUnknown", "optional unknown", "", InputPrimitiveType.Any, false, false, false), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), + new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), true, false, false, Array.Empty()), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), true, false, false, Array.Empty()), + new InputModelProperty("optionalUnknown", "optional unknown", "", InputPrimitiveType.Any, false, false, false, Array.Empty()), }; MockHelpers.LoadMockPlugin(createCSharpTypeCore: (InputType inputType) => @@ -126,7 +127,7 @@ public void BuildConstructor_ValidateConstructors() } }); - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); var modelTypeProvider = new ModelProvider(inputModel); var ctors = modelTypeProvider.Constructors; @@ -144,16 +145,16 @@ public void BuildConstructor_ValidateConstructorsInDerivedModel() { var baseProperties = new List { - new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false), - new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false), + new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), }; var derivedProperties = new List { - new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false), - new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false), + new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), }; - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); ((List)inputBase.DerivedModels).Add(inputDerived); MockHelpers.LoadMockPlugin(); @@ -183,8 +184,8 @@ public void BuildConstructor_ValidateConstructorsInDerivedModel() [Test] public void BuildBaseType() { - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, [], null, new List(), null, null, new Dictionary(), null, false); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, [], inputBase, new List(), null, null, new Dictionary(), null, false); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, [], null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, [], inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); ((List)inputBase.DerivedModels).Add(inputDerived); MockHelpers.LoadMockPlugin(); @@ -200,8 +201,8 @@ public void BuildModelAsStruct() { var properties = new List { - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), }; MockHelpers.LoadMockPlugin(createCSharpTypeCore: (InputType inputType) => @@ -218,7 +219,7 @@ public void BuildModelAsStruct() } }); - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, modelAsStruct: true); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.RoundTrip, properties, null, Array.Empty(), null, null, new Dictionary(), null, modelAsStruct: true, decorators: Array.Empty()); var modelTypeProvider = new ModelProvider(inputModel); Assert.AreEqual(TypeSignatureModifiers.Public | TypeSignatureModifiers.Struct | TypeSignatureModifiers.Partial | TypeSignatureModifiers.ReadOnly, modelTypeProvider.DeclarationModifiers); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs index 3863ff1f63c..0464fcd554f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Statements; using NUnit.Framework; @@ -66,27 +67,27 @@ public static IEnumerable BuildPropertyDescriptionTestCases { // list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IList))); // list of binary data property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.Any)), false, true, false), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", new InputPrimitiveType(InputPrimitiveTypeKind.Any), Array.Empty()), false, true, false, Array.Empty()), new CSharpType(typeof(IReadOnlyList))); // dictionary property with binary data value yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.Any)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.Any), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IDictionary))); // nullable dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String)), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), false, false, false, Array.Empty()), new CSharpType(typeof(IDictionary), true)); // primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, false, false), + new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.String), false, false, false, Array.Empty()), new CSharpType(typeof(string))); // binary data property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.Any), false, true, false), + new InputModelProperty("prop1", "prop1", "public", new InputPrimitiveType(InputPrimitiveTypeKind.Any), false, true, false, Array.Empty()), new CSharpType(typeof(BinaryData))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs index 675a00de133..d93e6242bfc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -24,10 +26,11 @@ public void TestSnakeCaseProperty() "snake_case", "snake_case", "A property with snake_case name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var property = new PropertyProvider(inputModelProperty); @@ -44,10 +47,11 @@ public void TestPascalCaseProperty() "PascalCase", "PascalCase", "A property with PascalCase name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var property = new PropertyProvider(inputModelProperty); @@ -64,10 +68,11 @@ public void TestCamelCaseProperty() "camelCase", "camelCase", "A property with camelCase name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var property = new PropertyProvider(inputModelProperty); @@ -84,10 +89,11 @@ public void TestKebabCaseProperty() "kebab-case", "kebab-case", "A property with kebab-case name", - new InputPrimitiveType(InputPrimitiveTypeKind.String, null), + new InputPrimitiveType(InputPrimitiveTypeKind.String), true, false, - false); + false, + Array.Empty()); var property = new PropertyProvider(inputModelProperty); @@ -116,19 +122,21 @@ private static IEnumerable CollectionPropertyTestCases() yield return new TestCaseData( new CSharpType(typeof(IList<>), typeof(string)), new InputModelProperty("readOnlyCollection", "readOnlyCollection", string.Empty, - new InputArrayType("List", "id", new InputPrimitiveType(InputPrimitiveTypeKind.String)), + new InputArrayType("List", "id", new InputPrimitiveType(InputPrimitiveTypeKind.String), Array.Empty()), true, true, - false), + false, + Array.Empty()), new CSharpType(typeof(IReadOnlyList<>), typeof(string))); // Dictionary -> IReadOnlyDictionary yield return new TestCaseData( new CSharpType(typeof(IDictionary<,>), typeof(string), typeof(int)), new InputModelProperty("readOnlyDictionary", "readOnlyDictionary", string.Empty, - new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.Int32)), + new InputDictionaryType("Dictionary", new InputPrimitiveType(InputPrimitiveTypeKind.String), new InputPrimitiveType(InputPrimitiveTypeKind.Int32), Array.Empty()), true, true, - false), + false, + Array.Empty()), new CSharpType(typeof(IReadOnlyDictionary<,>), typeof(string), typeof(int))); // string -> string yield return new TestCaseData( @@ -137,7 +145,7 @@ private static IEnumerable CollectionPropertyTestCases() new InputPrimitiveType(InputPrimitiveTypeKind.String), true, true, - false), + false, Array.Empty()), new CSharpType(typeof(string))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs index 84da3bba3a9..4080fb464f2 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs @@ -1,7 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using NUnit.Framework; @@ -27,7 +29,8 @@ public void ExtensibleStringEnumType() InputModelTypeUsage.Input, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true); + true, + Array.Empty()); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, true, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(input); @@ -48,8 +51,9 @@ public void ExtensibleStringNullableEnumType() InputModelTypeUsage.Input, new InputPrimitiveType(InputPrimitiveTypeKind.String, null, true), [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true); - var nullableInput = new InputNullableType(input); + true, + Array.Empty()); + var nullableInput = new InputNullableType(input, Array.Empty()); var expected = new CSharpType("SampleType", "Sample.Models", true, true, null, [], true, true, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(nullableInput); @@ -70,7 +74,8 @@ public void ExtensibleStringEnumTypeProvider() InputModelTypeUsage.Input, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true); + true, + Array.Empty()); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, true, underlyingEnumType: typeof(string)); var enumProvider = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); @@ -91,7 +96,8 @@ public void FixedStringEnumType() InputModelTypeUsage.Input, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false); + false, + Array.Empty()); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, false, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(input); @@ -112,7 +118,8 @@ public void CreateSameEnum() InputModelTypeUsage.Input, new InputPrimitiveType(InputPrimitiveTypeKind.String), [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false); + false, + Array.Empty()); var expected = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); var actual = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs index dedea041c24..e4fcaeca99d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; @@ -43,7 +44,7 @@ public void TypeProviderWriter_WriteModel() MockHelpers.LoadMockPlugin(createCSharpTypeCore: MockPluginSetValue(properties)); var inputModel = new InputModelType("TestModel", string.Empty, "public", null, "Test model.", InputModelTypeUsage.RoundTrip, - properties, null, new List(), null, null, new Dictionary(), null, false); + properties, null, new List(), null, null, new Dictionary(), null, false, decorators: Array.Empty()); var modelProvider = new ModelProvider(inputModel); var codeFile = new TypeProviderWriter(modelProvider).Write(); @@ -61,7 +62,7 @@ public void TypeProviderWriter_WriteModelAsStruct() MockHelpers.LoadMockPlugin(createCSharpTypeCore: MockPluginSetValue(properties)); var inputModel = new InputModelType("TestModel", string.Empty, "public", null, "Test model.", InputModelTypeUsage.RoundTrip, - properties, null, new List(), null, null, new Dictionary(), null, modelAsStruct: true); + properties, null, new List(), null, null, new Dictionary(), null, modelAsStruct: true, decorators: Array.Empty()); var modelProvider = new ModelProvider(inputModel); var codeFile = new TypeProviderWriter(modelProvider).Write(); @@ -104,12 +105,12 @@ private Func MockPluginSetValue(List } // common usages definitions - internal static readonly InputModelProperty RequiredStringProperty = new InputModelProperty("requiredString", "requiredString", "Required string, illustrating a reference type property.", InputPrimitiveType.String, true, false, false); + internal static readonly InputModelProperty RequiredStringProperty = new InputModelProperty("requiredString", "requiredString", "Required string, illustrating a reference type property.", InputPrimitiveType.String, true, false, false, Array.Empty()); - internal static readonly InputModelProperty RequiredIntProperty = new InputModelProperty("requiredInt", "requiredInt", "Required int, illustrating a value type property.", InputPrimitiveType.Int32, true, false, false); + internal static readonly InputModelProperty RequiredIntProperty = new InputModelProperty("requiredInt", "requiredInt", "Required int, illustrating a value type property.", InputPrimitiveType.Int32, true, false, false, Array.Empty()); - internal static readonly InputModelProperty RequiredStringListProperty = new InputModelProperty("requiredStringList", "requiredStringList", "Required collection of strings, illustrating a collection of reference types.", new InputArrayType("requiredStringList", "TypeSpec.Array", InputPrimitiveType.String), true, false, false); + internal static readonly InputModelProperty RequiredStringListProperty = new InputModelProperty("requiredStringList", "requiredStringList", "Required collection of strings, illustrating a collection of reference types.", new InputArrayType("requiredStringList", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()); - internal static readonly InputModelProperty RequiredIntListProperty = new InputModelProperty("requiredIntList", "requiredIntList", "Required collection of ints, illustrating a collection of value types.", new InputArrayType("requiredIntList", "TypeSpec.Array", InputPrimitiveType.Int32), true, false, false); + internal static readonly InputModelProperty RequiredIntListProperty = new InputModelProperty("requiredIntList", "requiredIntList", "Required collection of ints, illustrating a collection of value types.", new InputArrayType("requiredIntList", "TypeSpec.Array", InputPrimitiveType.Int32, Array.Empty()), true, false, false, Array.Empty()); } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json index 489eb36baf6..f817b5c3ff5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json @@ -1333,25 +1333,15 @@ "CrossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithProjectedName", "Usage": "Output", "Description": "this is a model with a projected name", - "Decorators": [ - { - "$id": "176", - "name": "TypeSpec.@projectedName", - "arguments": { - "$id": "177", - "targetName": "client", - "projectedName": "ProjectedModel" - } - } - ], + "Decorators": [], "Properties": [ { - "$id": "178", + "$id": "176", "Name": "name", "SerializedName": "name", "Description": "name of the ModelWithProjectedName", "Type": { - "$id": "179", + "$id": "177", "Kind": "string", "Decorators": [] }, @@ -1362,7 +1352,7 @@ ] }, { - "$id": "180", + "$id": "178", "Kind": "model", "Name": "ReturnsAnonymousModelResponse", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.returnsAnonymousModel.Response.anonymous", @@ -1371,7 +1361,7 @@ "Properties": [] }, { - "$id": "181", + "$id": "179", "Kind": "model", "Name": "AnonymousBodyRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.anonymousBody.Request.anonymous", @@ -1379,12 +1369,12 @@ "Decorators": [], "Properties": [ { - "$id": "182", + "$id": "180", "Name": "name", "SerializedName": "name", "Description": "name of the Thing", "Type": { - "$id": "183", + "$id": "181", "Kind": "string", "Decorators": [] }, @@ -1393,26 +1383,26 @@ "Decorators": [] }, { - "$id": "184", + "$id": "182", "Name": "requiredUnion", "SerializedName": "requiredUnion", "Description": "required Union", "Type": { - "$id": "185", + "$id": "183", "Kind": "union", "Name": "ThingRequiredUnion", "VariantTypes": [ { - "$id": "186", + "$id": "184", "Kind": "string", "Decorators": [] }, { - "$id": "187", + "$id": "185", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "188", + "$id": "186", "Kind": "string", "Decorators": [] }, @@ -1420,7 +1410,7 @@ "Decorators": [] }, { - "$id": "189", + "$id": "187", "Kind": "int32", "Decorators": [] } @@ -1432,12 +1422,12 @@ "Decorators": [] }, { - "$id": "190", + "$id": "188", "Name": "requiredLiteralString", "SerializedName": "requiredLiteralString", "Description": "required literal string", "Type": { - "$id": "191", + "$id": "189", "Kind": "constant", "ValueType": { "$ref": "60" @@ -1450,12 +1440,12 @@ "Decorators": [] }, { - "$id": "192", + "$id": "190", "Name": "requiredLiteralInt", "SerializedName": "requiredLiteralInt", "Description": "required literal int", "Type": { - "$id": "193", + "$id": "191", "Kind": "constant", "ValueType": { "$ref": "63" @@ -1468,12 +1458,12 @@ "Decorators": [] }, { - "$id": "194", + "$id": "192", "Name": "requiredLiteralFloat", "SerializedName": "requiredLiteralFloat", "Description": "required literal float", "Type": { - "$id": "195", + "$id": "193", "Kind": "constant", "ValueType": { "$ref": "66" @@ -1486,15 +1476,15 @@ "Decorators": [] }, { - "$id": "196", + "$id": "194", "Name": "requiredLiteralBool", "SerializedName": "requiredLiteralBool", "Description": "required literal bool", "Type": { - "$id": "197", + "$id": "195", "Kind": "constant", "ValueType": { - "$id": "198", + "$id": "196", "Kind": "boolean", "Decorators": [] }, @@ -1506,12 +1496,12 @@ "Decorators": [] }, { - "$id": "199", + "$id": "197", "Name": "optionalLiteralString", "SerializedName": "optionalLiteralString", "Description": "optional literal string", "Type": { - "$id": "200", + "$id": "198", "Kind": "constant", "ValueType": { "$ref": "69" @@ -1524,12 +1514,12 @@ "Decorators": [] }, { - "$id": "201", + "$id": "199", "Name": "optionalLiteralInt", "SerializedName": "optionalLiteralInt", "Description": "optional literal int", "Type": { - "$id": "202", + "$id": "200", "Kind": "constant", "ValueType": { "$ref": "72" @@ -1542,12 +1532,12 @@ "Decorators": [] }, { - "$id": "203", + "$id": "201", "Name": "optionalLiteralFloat", "SerializedName": "optionalLiteralFloat", "Description": "optional literal float", "Type": { - "$id": "204", + "$id": "202", "Kind": "constant", "ValueType": { "$ref": "75" @@ -1560,15 +1550,15 @@ "Decorators": [] }, { - "$id": "205", + "$id": "203", "Name": "optionalLiteralBool", "SerializedName": "optionalLiteralBool", "Description": "optional literal bool", "Type": { - "$id": "206", + "$id": "204", "Kind": "constant", "ValueType": { - "$id": "207", + "$id": "205", "Kind": "boolean", "Decorators": [] }, @@ -1580,12 +1570,12 @@ "Decorators": [] }, { - "$id": "208", + "$id": "206", "Name": "requiredBadDescription", "SerializedName": "requiredBadDescription", "Description": "description with xml <|endoftext|>", "Type": { - "$id": "209", + "$id": "207", "Kind": "string", "Decorators": [] }, @@ -1594,19 +1584,19 @@ "Decorators": [] }, { - "$id": "210", + "$id": "208", "Name": "optionalNullableList", "SerializedName": "optionalNullableList", "Description": "optional nullable collection", "Type": { - "$id": "211", + "$id": "209", "Kind": "nullable", "Type": { - "$id": "212", + "$id": "210", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "213", + "$id": "211", "Kind": "int32", "Decorators": [] }, @@ -1619,19 +1609,19 @@ "Decorators": [] }, { - "$id": "214", + "$id": "212", "Name": "requiredNullableList", "SerializedName": "requiredNullableList", "Description": "required nullable collection", "Type": { - "$id": "215", + "$id": "213", "Kind": "nullable", "Type": { - "$id": "216", + "$id": "214", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "217", + "$id": "215", "Kind": "int32", "Decorators": [] }, @@ -1646,7 +1636,7 @@ ] }, { - "$id": "218", + "$id": "216", "Kind": "model", "Name": "FriendlyModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.friendlyModel.Request.anonymous", @@ -1654,12 +1644,12 @@ "Decorators": [], "Properties": [ { - "$id": "219", + "$id": "217", "Name": "name", "SerializedName": "name", "Description": "name of the NotFriend", "Type": { - "$id": "220", + "$id": "218", "Kind": "string", "Decorators": [] }, @@ -1670,7 +1660,7 @@ ] }, { - "$id": "221", + "$id": "219", "Kind": "model", "Name": "ProjectedNameModelRequest", "CrossLanguageDefinitionId": "UnbrandedTypeSpec.projectedNameModel.Request.anonymous", @@ -1678,12 +1668,12 @@ "Decorators": [], "Properties": [ { - "$id": "222", + "$id": "220", "Name": "name", "SerializedName": "name", "Description": "name of the ModelWithProjectedName", "Type": { - "$id": "223", + "$id": "221", "Kind": "string", "Decorators": [] }, @@ -1696,23 +1686,23 @@ ], "Clients": [ { - "$id": "224", + "$id": "222", "Name": "UnbrandedTypeSpecClient", "Description": "This is a sample typespec project.", "Operations": [ { - "$id": "225", + "$id": "223", "Name": "sayHi", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi", "Accessibility": "public", "Parameters": [ { - "$id": "226", + "$id": "224", "Name": "unbrandedTypeSpecUrl", "NameInRequest": "unbrandedTypeSpecUrl", "Type": { - "$id": "227", + "$id": "225", "Kind": "url" }, "Location": "Uri", @@ -1726,11 +1716,11 @@ "Kind": "Client" }, { - "$id": "228", + "$id": "226", "Name": "headParameter", "NameInRequest": "head-parameter", "Type": { - "$id": "229", + "$id": "227", "Kind": "string", "Decorators": [] }, @@ -1745,11 +1735,11 @@ "Kind": "Method" }, { - "$id": "230", + "$id": "228", "Name": "queryParameter", "NameInRequest": "queryParameter", "Type": { - "$id": "231", + "$id": "229", "Kind": "string", "Decorators": [] }, @@ -1764,11 +1754,11 @@ "Kind": "Method" }, { - "$id": "232", + "$id": "230", "Name": "optionalQuery", "NameInRequest": "optionalQuery", "Type": { - "$id": "233", + "$id": "231", "Kind": "string", "Decorators": [] }, @@ -1783,11 +1773,11 @@ "Kind": "Method" }, { - "$id": "234", + "$id": "232", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "235", + "$id": "233", "Kind": "string" }, "Location": "Header", @@ -1800,9 +1790,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "236", + "$id": "234", "Type": { - "$ref": "235" + "$ref": "233" }, "Value": "application/json" } @@ -1810,7 +1800,7 @@ ], "Responses": [ { - "$id": "237", + "$id": "235", "StatusCodes": [ 200 ], @@ -1834,21 +1824,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "238", + "$id": "236", "Name": "helloAgain", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi again", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "239", + "$id": "237", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "240", + "$id": "238", "Kind": "string", "Decorators": [] }, @@ -1863,14 +1853,14 @@ "Kind": "Method" }, { - "$id": "241", + "$id": "239", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "242", + "$id": "240", "Kind": "constant", "ValueType": { - "$id": "243", + "$id": "241", "Kind": "string", "Decorators": [] }, @@ -1879,9 +1869,9 @@ }, "Location": "Header", "DefaultValue": { - "$id": "244", + "$id": "242", "Type": { - "$ref": "242" + "$ref": "240" }, "Value": "text/plain" }, @@ -1895,11 +1885,11 @@ "Kind": "Constant" }, { - "$id": "245", + "$id": "243", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "246", + "$id": "244", "Kind": "string", "Decorators": [] }, @@ -1914,7 +1904,7 @@ "Kind": "Method" }, { - "$id": "247", + "$id": "245", "Name": "action", "NameInRequest": "action", "Type": { @@ -1931,11 +1921,11 @@ "Kind": "Method" }, { - "$id": "248", + "$id": "246", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "249", + "$id": "247", "Kind": "string" }, "Location": "Header", @@ -1948,9 +1938,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "250", + "$id": "248", "Type": { - "$ref": "249" + "$ref": "247" }, "Value": "application/json" } @@ -1958,7 +1948,7 @@ ], "Responses": [ { - "$id": "251", + "$id": "249", "StatusCodes": [ 200 ], @@ -1985,21 +1975,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "252", + "$id": "250", "Name": "noContentType", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi again", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "253", + "$id": "251", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "254", + "$id": "252", "Kind": "string", "Decorators": [] }, @@ -2014,11 +2004,11 @@ "Kind": "Method" }, { - "$id": "255", + "$id": "253", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "256", + "$id": "254", "Kind": "string", "Decorators": [] }, @@ -2033,7 +2023,7 @@ "Kind": "Method" }, { - "$id": "257", + "$id": "255", "Name": "action", "NameInRequest": "action", "Type": { @@ -2050,11 +2040,11 @@ "Kind": "Method" }, { - "$id": "258", + "$id": "256", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "259", + "$id": "257", "Kind": "string" }, "Location": "Header", @@ -2067,19 +2057,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "260", + "$id": "258", "Type": { - "$ref": "259" + "$ref": "257" }, "Value": "application/json" } }, { - "$id": "261", + "$id": "259", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "262", + "$id": "260", "Kind": "string" }, "Location": "Header", @@ -2092,9 +2082,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "263", + "$id": "261", "Type": { - "$ref": "262" + "$ref": "260" }, "Value": "application/json" } @@ -2102,7 +2092,7 @@ ], "Responses": [ { - "$id": "264", + "$id": "262", "StatusCodes": [ 200 ], @@ -2129,21 +2119,21 @@ "GenerateConvenienceMethod": false }, { - "$id": "265", + "$id": "263", "Name": "helloDemo2", "ResourceName": "UnbrandedTypeSpec", "Description": "Return hi in demo2", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "266", + "$id": "264", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "267", + "$id": "265", "Kind": "string" }, "Location": "Header", @@ -2156,9 +2146,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "268", + "$id": "266", "Type": { - "$ref": "267" + "$ref": "265" }, "Value": "application/json" } @@ -2166,7 +2156,7 @@ ], "Responses": [ { - "$id": "269", + "$id": "267", "StatusCodes": [ 200 ], @@ -2190,17 +2180,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "270", + "$id": "268", "Name": "createLiteral", "ResourceName": "UnbrandedTypeSpec", "Description": "Create with literal value", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "271", + "$id": "269", "Name": "body", "NameInRequest": "body", "Type": { @@ -2217,11 +2207,11 @@ "Kind": "Method" }, { - "$id": "272", + "$id": "270", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "273", + "$id": "271", "Kind": "string" }, "Location": "Header", @@ -2234,19 +2224,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "274", + "$id": "272", "Type": { - "$ref": "273" + "$ref": "271" }, "Value": "application/json" } }, { - "$id": "275", + "$id": "273", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "276", + "$id": "274", "Kind": "string" }, "Location": "Header", @@ -2259,9 +2249,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "277", + "$id": "275", "Type": { - "$ref": "276" + "$ref": "274" }, "Value": "application/json" } @@ -2269,7 +2259,7 @@ ], "Responses": [ { - "$id": "278", + "$id": "276", "StatusCodes": [ 200 ], @@ -2296,24 +2286,24 @@ "GenerateConvenienceMethod": true }, { - "$id": "279", + "$id": "277", "Name": "helloLiteral", "ResourceName": "UnbrandedTypeSpec", "Description": "Send literal parameters", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "280", + "$id": "278", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "281", + "$id": "279", "Kind": "constant", "ValueType": { - "$id": "282", + "$id": "280", "Kind": "string", "Decorators": [] }, @@ -2322,9 +2312,9 @@ }, "Location": "Header", "DefaultValue": { - "$id": "283", + "$id": "281", "Type": { - "$ref": "281" + "$ref": "279" }, "Value": "test" }, @@ -2338,14 +2328,14 @@ "Kind": "Constant" }, { - "$id": "284", + "$id": "282", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "285", + "$id": "283", "Kind": "constant", "ValueType": { - "$id": "286", + "$id": "284", "Kind": "int32", "Decorators": [] }, @@ -2354,9 +2344,9 @@ }, "Location": "Path", "DefaultValue": { - "$id": "287", + "$id": "285", "Type": { - "$ref": "285" + "$ref": "283" }, "Value": 123 }, @@ -2370,14 +2360,14 @@ "Kind": "Constant" }, { - "$id": "288", + "$id": "286", "Name": "p3", "NameInRequest": "p3", "Type": { - "$id": "289", + "$id": "287", "Kind": "constant", "ValueType": { - "$id": "290", + "$id": "288", "Kind": "boolean", "Decorators": [] }, @@ -2386,9 +2376,9 @@ }, "Location": "Query", "DefaultValue": { - "$id": "291", + "$id": "289", "Type": { - "$ref": "289" + "$ref": "287" }, "Value": true }, @@ -2402,11 +2392,11 @@ "Kind": "Constant" }, { - "$id": "292", + "$id": "290", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "293", + "$id": "291", "Kind": "string" }, "Location": "Header", @@ -2419,9 +2409,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "294", + "$id": "292", "Type": { - "$ref": "293" + "$ref": "291" }, "Value": "application/json" } @@ -2429,7 +2419,7 @@ ], "Responses": [ { - "$id": "295", + "$id": "293", "StatusCodes": [ 200 ], @@ -2453,25 +2443,25 @@ "GenerateConvenienceMethod": true }, { - "$id": "296", + "$id": "294", "Name": "topAction", "ResourceName": "UnbrandedTypeSpec", "Description": "top level method", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "297", + "$id": "295", "Name": "action", "NameInRequest": "action", "Type": { - "$id": "298", + "$id": "296", "Kind": "utcDateTime", "Encode": "rfc3339", "WireType": { - "$id": "299", + "$id": "297", "Kind": "string", "Decorators": [] }, @@ -2488,11 +2478,11 @@ "Kind": "Method" }, { - "$id": "300", + "$id": "298", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "301", + "$id": "299", "Kind": "string" }, "Location": "Header", @@ -2505,9 +2495,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "302", + "$id": "300", "Type": { - "$ref": "301" + "$ref": "299" }, "Value": "application/json" } @@ -2515,7 +2505,7 @@ ], "Responses": [ { - "$id": "303", + "$id": "301", "StatusCodes": [ 200 ], @@ -2539,21 +2529,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "304", + "$id": "302", "Name": "topAction2", "ResourceName": "UnbrandedTypeSpec", "Description": "top level method2", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "305", + "$id": "303", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "306", + "$id": "304", "Kind": "string" }, "Location": "Header", @@ -2566,9 +2556,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "307", + "$id": "305", "Type": { - "$ref": "306" + "$ref": "304" }, "Value": "application/json" } @@ -2576,7 +2566,7 @@ ], "Responses": [ { - "$id": "308", + "$id": "306", "StatusCodes": [ 200 ], @@ -2600,17 +2590,17 @@ "GenerateConvenienceMethod": false }, { - "$id": "309", + "$id": "307", "Name": "patchAction", "ResourceName": "UnbrandedTypeSpec", "Description": "top level patch", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "310", + "$id": "308", "Name": "body", "NameInRequest": "body", "Type": { @@ -2627,11 +2617,11 @@ "Kind": "Method" }, { - "$id": "311", + "$id": "309", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "312", + "$id": "310", "Kind": "string" }, "Location": "Header", @@ -2644,19 +2634,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "313", + "$id": "311", "Type": { - "$ref": "312" + "$ref": "310" }, "Value": "application/json" } }, { - "$id": "314", + "$id": "312", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "315", + "$id": "313", "Kind": "string" }, "Location": "Header", @@ -2669,9 +2659,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "316", + "$id": "314", "Type": { - "$ref": "315" + "$ref": "313" }, "Value": "application/json" } @@ -2679,7 +2669,7 @@ ], "Responses": [ { - "$id": "317", + "$id": "315", "StatusCodes": [ 200 ], @@ -2706,17 +2696,17 @@ "GenerateConvenienceMethod": false }, { - "$id": "318", + "$id": "316", "Name": "anonymousBody", "ResourceName": "UnbrandedTypeSpec", "Description": "body parameter without body decorator", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "319", + "$id": "317", "Name": "Thing", "NameInRequest": "Thing", "Description": "A model with a few properties of literal types", @@ -2734,11 +2724,11 @@ "Kind": "Spread" }, { - "$id": "320", + "$id": "318", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "321", + "$id": "319", "Kind": "string" }, "Location": "Header", @@ -2751,19 +2741,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "322", + "$id": "320", "Type": { - "$ref": "321" + "$ref": "319" }, "Value": "application/json" } }, { - "$id": "323", + "$id": "321", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "324", + "$id": "322", "Kind": "string" }, "Location": "Header", @@ -2776,9 +2766,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "325", + "$id": "323", "Type": { - "$ref": "324" + "$ref": "322" }, "Value": "application/json" } @@ -2786,7 +2776,7 @@ ], "Responses": [ { - "$id": "326", + "$id": "324", "StatusCodes": [ 200 ], @@ -2813,17 +2803,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "327", + "$id": "325", "Name": "friendlyModel", "ResourceName": "UnbrandedTypeSpec", "Description": "Model can have its friendly name", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "328", + "$id": "326", "Name": "Friend", "NameInRequest": "NotFriend", "Description": "this is not a friendly model but with a friendly name", @@ -2841,11 +2831,11 @@ "Kind": "Spread" }, { - "$id": "329", + "$id": "327", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "330", + "$id": "328", "Kind": "string" }, "Location": "Header", @@ -2858,19 +2848,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "331", + "$id": "329", "Type": { - "$ref": "330" + "$ref": "328" }, "Value": "application/json" } }, { - "$id": "332", + "$id": "330", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "333", + "$id": "331", "Kind": "string" }, "Location": "Header", @@ -2883,9 +2873,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "334", + "$id": "332", "Type": { - "$ref": "333" + "$ref": "331" }, "Value": "application/json" } @@ -2893,7 +2883,7 @@ ], "Responses": [ { - "$id": "335", + "$id": "333", "StatusCodes": [ 200 ], @@ -2920,24 +2910,24 @@ "GenerateConvenienceMethod": true }, { - "$id": "336", + "$id": "334", "Name": "addTimeHeader", "ResourceName": "UnbrandedTypeSpec", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "337", + "$id": "335", "Name": "repeatabilityFirstSent", "NameInRequest": "Repeatability-First-Sent", "Type": { - "$id": "338", + "$id": "336", "Kind": "utcDateTime", "Encode": "rfc7231", "WireType": { - "$id": "339", + "$id": "337", "Kind": "string", "Decorators": [] }, @@ -2954,11 +2944,11 @@ "Kind": "Method" }, { - "$id": "340", + "$id": "338", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "341", + "$id": "339", "Kind": "string" }, "Location": "Header", @@ -2971,9 +2961,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "342", + "$id": "340", "Type": { - "$ref": "341" + "$ref": "339" }, "Value": "application/json" } @@ -2981,7 +2971,7 @@ ], "Responses": [ { - "$id": "343", + "$id": "341", "StatusCodes": [ 204 ], @@ -2999,17 +2989,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "344", + "$id": "342", "Name": "projectedNameModel", "ResourceName": "UnbrandedTypeSpec", "Description": "Model can have its projected name", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "345", + "$id": "343", "Name": "ProjectedModel", "NameInRequest": "ModelWithProjectedName", "Description": "this is a model with a projected name", @@ -3027,11 +3017,11 @@ "Kind": "Spread" }, { - "$id": "346", + "$id": "344", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "347", + "$id": "345", "Kind": "string" }, "Location": "Header", @@ -3044,19 +3034,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "348", + "$id": "346", "Type": { - "$ref": "347" + "$ref": "345" }, "Value": "application/json" } }, { - "$id": "349", + "$id": "347", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "350", + "$id": "348", "Kind": "string" }, "Location": "Header", @@ -3069,9 +3059,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "351", + "$id": "349", "Type": { - "$ref": "350" + "$ref": "348" }, "Value": "application/json" } @@ -3079,7 +3069,7 @@ ], "Responses": [ { - "$id": "352", + "$id": "350", "StatusCodes": [ 200 ], @@ -3106,21 +3096,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "353", + "$id": "351", "Name": "returnsAnonymousModel", "ResourceName": "UnbrandedTypeSpec", "Description": "return anonymous model", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "354", + "$id": "352", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "355", + "$id": "353", "Kind": "string" }, "Location": "Header", @@ -3133,9 +3123,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "356", + "$id": "354", "Type": { - "$ref": "355" + "$ref": "353" }, "Value": "application/json" } @@ -3143,12 +3133,12 @@ ], "Responses": [ { - "$id": "357", + "$id": "355", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "180" + "$ref": "178" }, "BodyMediaType": "Json", "Headers": [], @@ -3167,21 +3157,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "358", + "$id": "356", "Name": "getUnknownValue", "ResourceName": "UnbrandedTypeSpec", "Description": "get extensible enum", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "359", + "$id": "357", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "360", + "$id": "358", "Kind": "string" }, "Location": "Header", @@ -3194,9 +3184,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "361", + "$id": "359", "Type": { - "$ref": "360" + "$ref": "358" }, "Value": "application/json" } @@ -3204,12 +3194,12 @@ ], "Responses": [ { - "$id": "362", + "$id": "360", "StatusCodes": [ 200 ], "BodyType": { - "$id": "363", + "$id": "361", "Kind": "string", "Decorators": [] }, @@ -3230,17 +3220,17 @@ "GenerateConvenienceMethod": true }, { - "$id": "364", + "$id": "362", "Name": "internalProtocol", "ResourceName": "UnbrandedTypeSpec", "Description": "When set protocol false and convenient true, then the protocol method should be internal", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "365", + "$id": "363", "Name": "body", "NameInRequest": "body", "Type": { @@ -3257,11 +3247,11 @@ "Kind": "Method" }, { - "$id": "366", + "$id": "364", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "367", + "$id": "365", "Kind": "string" }, "Location": "Header", @@ -3274,19 +3264,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "368", + "$id": "366", "Type": { - "$ref": "367" + "$ref": "365" }, "Value": "application/json" } }, { - "$id": "369", + "$id": "367", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "370", + "$id": "368", "Kind": "string" }, "Location": "Header", @@ -3299,9 +3289,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "371", + "$id": "369", "Type": { - "$ref": "370" + "$ref": "368" }, "Value": "application/json" } @@ -3309,7 +3299,7 @@ ], "Responses": [ { - "$id": "372", + "$id": "370", "StatusCodes": [ 200 ], @@ -3336,21 +3326,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "373", + "$id": "371", "Name": "stillConvenient", "ResourceName": "UnbrandedTypeSpec", "Description": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "374", + "$id": "372", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "375", + "$id": "373", "Kind": "string" }, "Location": "Header", @@ -3363,9 +3353,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "376", + "$id": "374", "Type": { - "$ref": "375" + "$ref": "373" }, "Value": "application/json" } @@ -3373,7 +3363,7 @@ ], "Responses": [ { - "$id": "377", + "$id": "375", "StatusCodes": [ 204 ], @@ -3391,21 +3381,21 @@ "GenerateConvenienceMethod": true }, { - "$id": "378", + "$id": "376", "Name": "headAsBoolean", "ResourceName": "UnbrandedTypeSpec", "Description": "head as boolean.", "Accessibility": "public", "Parameters": [ { - "$ref": "226" + "$ref": "224" }, { - "$id": "379", + "$id": "377", "Name": "id", "NameInRequest": "id", "Type": { - "$id": "380", + "$id": "378", "Kind": "string", "Decorators": [] }, @@ -3420,11 +3410,11 @@ "Kind": "Method" }, { - "$id": "381", + "$id": "379", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "382", + "$id": "380", "Kind": "string" }, "Location": "Header", @@ -3437,9 +3427,9 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "383", + "$id": "381", "Type": { - "$ref": "382" + "$ref": "380" }, "Value": "application/json" } @@ -3447,7 +3437,7 @@ ], "Responses": [ { - "$id": "384", + "$id": "382", "StatusCodes": [ 204 ], @@ -3466,20 +3456,20 @@ } ], "Protocol": { - "$id": "385" + "$id": "383" }, "Parameters": [ { - "$ref": "226" + "$ref": "224" } ], "Decorators": [] } ], "Auth": { - "$id": "386", + "$id": "384", "ApiKey": { - "$id": "387", + "$id": "385", "Name": "my-api-key" } } From 763c72a51ec5e6e92a90d4af761579e154a4740e Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Thu, 25 Jul 2024 13:19:06 +0800 Subject: [PATCH 07/26] update emitter unit test --- .../emitter/test/Unit/encode.test.ts | 12 ++++++++++++ .../emitter/test/Unit/model-type.test.ts | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/http-client-csharp/emitter/test/Unit/encode.test.ts b/packages/http-client-csharp/emitter/test/Unit/encode.test.ts index 3eeb9d02a7e..7f76f14c7da 100644 --- a/packages/http-client-csharp/emitter/test/Unit/encode.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/encode.test.ts @@ -51,7 +51,9 @@ describe("Test encode duration", () => { WireType: { Kind: "string", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, operation.Parameters[0].Type ); @@ -89,7 +91,9 @@ describe("Test encode duration", () => { WireType: { Kind: "int32", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, operation.Parameters[0].Type ); @@ -127,7 +131,9 @@ describe("Test encode duration", () => { WireType: { Kind: "float32", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, operation.Parameters[0].Type ); @@ -159,7 +165,9 @@ describe("Test encode duration", () => { WireType: { Kind: "string", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, durationProperty.Properties[0].Type ); @@ -191,7 +199,9 @@ describe("Test encode duration", () => { WireType: { Kind: "int32", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, durationProperty.Properties[0].Type ); @@ -223,7 +233,9 @@ describe("Test encode duration", () => { WireType: { Kind: "float32", Encode: undefined, + Decorators: [], }, + Decorators: [], } as InputDurationType, durationProperty.Properties[0].Type ); diff --git a/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts b/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts index 408ae18f911..5f2fea65c6c 100644 --- a/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/model-type.test.ts @@ -68,6 +68,7 @@ op test(@body input: Pet): Pet; Type: { Kind: "string", Encode: undefined, + Decorators: [], }, IsRequired: true, IsReadOnly: false, @@ -166,21 +167,25 @@ op test(@body input: Pet): Pet; ValueType: { Kind: "string", Encode: undefined, + Decorators: [], }, Values: [ { Name: "Cat", Value: "Cat", Description: undefined, + Decorators: [], }, { Name: "Dog", Value: "Dog", Description: undefined, + Decorators: [], }, ], IsExtensible: false, Usage: "RoundTrip", + Decorators: [], }, IsRequired: true, IsReadOnly: false, @@ -288,21 +293,25 @@ op test(@body input: Pet): Pet; ValueType: { Kind: "string", Encode: undefined, + Decorators: [], }, Values: [ { Name: "Cat", Value: "cat", Description: undefined, + Decorators: [], }, { Name: "Dog", Value: "dog", Description: undefined, + Decorators: [], }, ], IsExtensible: false, Usage: "RoundTrip", + Decorators: [], }, IsRequired: true, IsReadOnly: false, From ea197fc4a9ac18903f8209fe355f8fed982d37ec Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 26 Jul 2024 15:03:55 +0800 Subject: [PATCH 08/26] regen --- .../http/authentication/api-key/tspCodeModel.json | 10 +++++++--- .../http/authentication/http/custom/tspCodeModel.json | 10 +++++++--- .../http/authentication/oauth2/tspCodeModel.json | 10 +++++++--- .../http/authentication/union/tspCodeModel.json | 3 ++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json index a884cf43365..c55e5d068f5 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json @@ -10,6 +10,7 @@ "Name": "InvalidAuth", "CrossLanguageDefinitionId": "Authentication.ApiKey.InvalidAuth", "Usage": "Output,Error,Json", + "Decorators": [], "Properties": [ { "$id": "3", @@ -18,10 +19,12 @@ "Description": "", "Type": { "$id": "4", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } @@ -189,7 +192,8 @@ { "$ref": "7" } - ] + ], + "Decorators": [] } ], "Auth": { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json index e82b79c3170..cf7c03c1f21 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json @@ -10,6 +10,7 @@ "Name": "InvalidAuth", "CrossLanguageDefinitionId": "Authentication.Http.Custom.InvalidAuth", "Usage": "Output,Error,Json", + "Decorators": [], "Properties": [ { "$id": "3", @@ -18,10 +19,12 @@ "Description": "", "Type": { "$id": "4", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } @@ -189,7 +192,8 @@ { "$ref": "7" } - ] + ], + "Decorators": [] } ], "Auth": { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json index d2fed49fd04..b4a6a188ebf 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json @@ -10,6 +10,7 @@ "Name": "InvalidAuth", "CrossLanguageDefinitionId": "Authentication.OAuth2.InvalidAuth", "Usage": "Output,Error,Json", + "Decorators": [], "Properties": [ { "$id": "3", @@ -18,10 +19,12 @@ "Description": "", "Type": { "$id": "4", - "Kind": "string" + "Kind": "string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } @@ -189,7 +192,8 @@ { "$ref": "7" } - ] + ], + "Decorators": [] } ], "Auth": { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json index 2126391d3bf..6e782d328ca 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json @@ -152,7 +152,8 @@ { "$ref": "4" } - ] + ], + "Decorators": [] } ], "Auth": { From 2209a51c3b6c66938509f92221ff4404f2e76038 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Mon, 5 Aug 2024 14:49:39 +0800 Subject: [PATCH 09/26] format --- packages/http-client-csharp/emitter/src/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-csharp/emitter/src/emitter.ts b/packages/http-client-csharp/emitter/src/emitter.ts index e1cbee2543f..2135f7b01c5 100644 --- a/packages/http-client-csharp/emitter/src/emitter.ts +++ b/packages/http-client-csharp/emitter/src/emitter.ts @@ -136,7 +136,7 @@ export async function $onEmit(context: EmitContext) { const existingProjectOption = options["existing-project-folder"] ? `--existing-project-folder ${options["existing-project-folder"]}` : ""; - const debugFlag = options.debug ?? false ? " --debug" : ""; + const debugFlag = (options.debug ?? false) ? " --debug" : ""; const projectRoot = findProjectRoot(dirname(fileURLToPath(import.meta.url))); const generatorPath = resolvePath( From f1c24932f2f5437cb3f632768b6767fd21451e82 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Mon, 5 Aug 2024 16:58:52 +0800 Subject: [PATCH 10/26] resolve comments --- .../EnumProviderSerializationTests.cs | 2 +- .../JsonModelCoreTests.cs | 12 ++--- .../MrwSerializationConstructorTests.cs | 8 ++-- .../MrwSerializationTypeDefinitionTests.cs | 46 +++++++++---------- .../PersistableModelCoreTests.cs | 4 +- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs index 8823a220a43..0a223304271 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs @@ -33,7 +33,7 @@ public void Setup() new InputEnumTypeValue(stringA, intA, null), new InputEnumTypeValue(stringB, intB, null) }; - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, values, false, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, values, false, []); TypeProvider? enumType = ClientModelPlugin.Instance.TypeFactory.CreateEnum(input); return enumType!.SerializationProviders.FirstOrDefault(); } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index 24b4483d179..b564d1f66e8 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -48,7 +48,7 @@ public void KebabCaseSerializedName() true, false, false, - Array.Empty()); + []); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -64,7 +64,7 @@ public void KebabCaseSerializedName() new Dictionary(), null, false, - Array.Empty()); + []); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -118,7 +118,7 @@ public void PascalCaseSerializedName() true, false, false, - Array.Empty()); + []); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -134,7 +134,7 @@ public void PascalCaseSerializedName() new Dictionary(), null, false, - Array.Empty()); + []); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -153,7 +153,7 @@ public void CamelCaseSerializedName() true, false, false, - Array.Empty()); + []); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -169,7 +169,7 @@ public void CamelCaseSerializedName() new Dictionary(), null, false, - Array.Empty()); + []); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs index d8416ecfbb2..26179015cde 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs @@ -37,13 +37,13 @@ public void TestBuildConstructors() { var baseProperties = new List { - new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, []), + new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, []), }; var derivedProperties = new List { - new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, []), + new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, []), }; var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index 1f84a926eb6..213d8b734d2 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -41,7 +41,7 @@ internal static (TypeProvider Model, MrwSerializationTypeDefinition Serializatio public void TestBuildImplements() { // mock the model type provider - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var interfaces = serialization.Implements; @@ -58,7 +58,7 @@ public void TestBuildImplements() [Test] public void TestBuildJsonModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteCoreMethod(); @@ -93,7 +93,7 @@ public void TestBuildJsonModelWriteCoreMethod() [Test] public void TestBuildJsonModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteMethodObjectDeclaration(); @@ -127,7 +127,7 @@ public void TestBuildJsonModelWriteMethodObjectDeclaration() [Test] public void TestBuildJsonModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethod(); @@ -147,7 +147,7 @@ public void TestBuildJsonModelCreateMethod() [Test] public void TestBuildJsonModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateCoreMethod(); @@ -182,7 +182,7 @@ public void TestBuildJsonModelCreateCoreMethod() [Test] public void TestBuildJsonModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethodObjectDeclaration(); @@ -217,7 +217,7 @@ public void TestBuildJsonModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelWriteMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethod(); @@ -237,7 +237,7 @@ public void TestBuildPersistableModelWriteMethod() [Test] public void TestBuildPersistableModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteCoreMethod(); @@ -272,7 +272,7 @@ public void TestBuildPersistableModelWriteCoreMethod() [Test] public void TestBuildPersistableModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethodObjectDeclaration(); @@ -306,7 +306,7 @@ public void TestBuildPersistableModelWriteMethodObjectDeclaration() [Test] public void TestBuildPersistableModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -336,7 +336,7 @@ public void TestBuildPersistableModelCreateMethod() [Test] public void TestBuildPersistableModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); Assert.IsNotNull(serialization); @@ -365,7 +365,7 @@ public void TestBuildPersistableModelCreateCoreMethod() [Test] public void BuildPersistableModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethodObjectDeclaration(); @@ -399,7 +399,7 @@ public void BuildPersistableModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -419,7 +419,7 @@ public void TestBuildPersistableModelDeserializationMethod() [Test] public void TestBuildPersistableModelGetFormatMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsMethod(); @@ -442,7 +442,7 @@ public void TestBuildPersistableModelGetFormatMethod() [Test] public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsObjectDeclaration(); @@ -475,7 +475,7 @@ public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() [Test] public void TestBuildSerializationConstructor() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var constructor = serialization.BuildSerializationConstructor(); @@ -492,7 +492,7 @@ public void TestBuildSerializationConstructor() [Test] public void TestBuildFields() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var fields = serialization.Fields; @@ -512,11 +512,11 @@ public void TestBuildConstructor_ValidateConstructors() { new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), - new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()), + new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, []), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false, []), }; - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var ctors = serialization.Constructors; @@ -536,7 +536,7 @@ public void TestBuildConstructor_ValidateConstructors() [Test] public void TestBuildDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var deserializationMethod = serialization.BuildDeserializationMethod(); @@ -558,7 +558,7 @@ public void TestBuildDeserializationMethod() [Test] public void TestBuildImplicitToBinaryContent() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; @@ -586,7 +586,7 @@ public void TestBuildImplicitToBinaryContent() [Test] public void TestBuildExplicitFromClientResult() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs index 73a5476e44c..bbb0a0f3817 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs @@ -40,9 +40,9 @@ protected override MethodProvider[] BuildMethods() [Test] public void TestBuildPersistableModelCreateCoreMethod_DerivedType() { - var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, [], null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, [], null, new List(), null, null, new Dictionary(), null, false, []); var inputDerived = new InputModelType("mockDerivedModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, - [], inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + [], inputBase, new List(), null, null, new Dictionary(), null, false, []); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); var (derivedModel, derivedSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputDerived); From 80487013286b070b008e807e3e612f6e1ce56512 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Tue, 6 Aug 2024 10:04:03 +0800 Subject: [PATCH 11/26] move decorated type to Input namespace --- .../test/Providers/EnumProviderSerializationTests.cs | 2 -- .../MrwSerializationTypeDefinitions/JsonModelCoreTests.cs | 1 - .../MrwSerializationConstructorTests.cs | 1 - .../MrwSerializationTypeDefinitionTests.cs | 1 - .../PersistableModelCoreTests.cs | 2 -- .../src/InputTypes/InputArrayType.cs | 1 - .../src/InputTypes/InputDateTimeType.cs | 1 - .../src/InputTypes/InputDecoratedType.cs | 2 +- .../src/InputTypes/InputDecoratorInfo.cs | 2 +- .../src/InputTypes/InputDictionaryType.cs | 1 - .../src/InputTypes/InputDurationType.cs | 1 - .../src/InputTypes/InputEnumType.cs | 1 - .../src/InputTypes/InputLiteralType.cs | 1 - .../src/InputTypes/InputModelProperty.cs | 1 - .../src/InputTypes/InputModelType.cs | 1 - .../src/InputTypes/InputNullableType.cs | 1 - .../src/InputTypes/InputPrimitiveType.cs | 1 - .../src/InputTypes/InputType.cs | 1 - .../src/InputTypes/InputUnionType.cs | 1 - .../Serialization/TypeSpecInputArrayTypeConverter.cs | 1 - .../Serialization/TypeSpecInputDateTimeTypeConverter.cs | 1 - .../Serialization/TypeSpecInputDictionaryTypeConverter.cs | 1 - .../Serialization/TypeSpecInputDurationTypeConverter.cs | 1 - .../Serialization/TypeSpecInputEnumTypeConverter.cs | 1 - .../Serialization/TypeSpecInputLiteralTypeConverter.cs | 1 - .../Serialization/TypeSpecInputModelPropertyConverter.cs | 1 - .../Serialization/TypeSpecInputModelTypeConverter.cs | 1 - .../Serialization/TypeSpecInputNullableTypeConverter.cs | 1 - .../Serialization/TypeSpecInputUnionTypeConverter.cs | 1 - .../Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs | 1 - .../test/Expressions/NewInstanceExpressionTests.cs | 1 - .../test/InputLibraryVisitorTests.cs | 1 - .../test/Providers/EnumProviderTests.cs | 4 ---- .../test/Providers/ModelProviderTests.cs | 1 - .../test/Providers/PropertyDescriptionTests.cs | 1 - .../test/Providers/PropertyProviderTests.cs | 1 - .../Microsoft.Generator.CSharp/test/TypeFactoryTests.cs | 1 - .../test/Writers/TypeProviderWriterTests.cs | 1 - 38 files changed, 2 insertions(+), 43 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs index 0a223304271..208967c6e17 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs @@ -4,9 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Providers; using Microsoft.Generator.CSharp.Statements; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index b564d1f66e8..df0c2114d6f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -6,7 +6,6 @@ using System.Linq; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs index 26179015cde..f74c1461a4b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index 213d8b734d2..36647540b73 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -11,7 +11,6 @@ using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs index bbb0a0f3817..73240804c07 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs index 2b64f9328f3..f3b0ce2ad2b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs index ea7d6eb3b1c..3314025fcc7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs index b4764d2654a..dd21cf48342 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; -namespace Microsoft.Generator.CSharp.Input.InputTypes +namespace Microsoft.Generator.CSharp.Input { public class InputDecoratedType { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs index 54b6199487c..6c22c9f4967 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; -namespace Microsoft.Generator.CSharp.Input.InputTypes +namespace Microsoft.Generator.CSharp.Input { public class InputDecoratorInfo { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs index 0fdb439039d..80117b27ead 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs index 66ffee86157..d075781e90f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs index f707902b675..5aeb6aac1cf 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs index 3c3630e9253..e4eba7e2313 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 0f56f3797ba..49e0dc5f37f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index e56593348b0..da90380f385 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index 6d33134d6d3..1c51ad24d07 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs index 429d82577d4..df18be801a9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.Generator.CSharp.Input.InputTypes; using System; using System.Collections.Generic; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index e85c4415009..d4d6e46bf33 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs index 98db71c9986..84ac6180a16 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs index 011c6d44ff3..30da5e10e2c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs index 8b50a8c2a34..e589a6cdc6a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs index 6e54cdeee43..bf9d178aef1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs index bd8594a3363..fe224cd0038 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs index 62581029571..7b474406680 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs index b555e4c7a13..ba486230d9f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index a32b02f6ea1..1070ab127b8 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs index eb0fca21633..45bc8358985 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 9f3c456f651..11945d002e0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs index b89f52522dc..3ef1cfa336c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Generator.CSharp.Input.InputTypes; namespace Microsoft.Generator.CSharp.Input { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs index 7b654b3183c..6368cd43b02 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using BenchmarkDotNet.Attributes; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs index 4d07d1545c6..dd6543b3912 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using NUnit.Framework; using static Microsoft.Generator.CSharp.Snippets.Snippet; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs index a2181f33e81..5fad25e9bd6 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Providers; using Moq; using Moq.Protected; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index e26a0b60353..7224fc5327a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -2,14 +2,10 @@ // Licensed under the MIT License. using System; -using System.Linq; -using System.Text; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; -using Microsoft.Generator.CSharp.Snippets; using NUnit.Framework; namespace Microsoft.Generator.CSharp.Tests.Providers diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs index c9a60ed1b84..2e40c00b5cd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs index 082a02aa111..eb21a5d18bd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Statements; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs index 32e819f5ad6..b6c606ffa63 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs index d4af1830fe6..9286024f5d0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs @@ -3,7 +3,6 @@ using System; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using NUnit.Framework; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs index 0b48281771b..87e8a1c8e6f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Input.InputTypes; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using NUnit.Framework; From 5c27360563396f65602be201f202e67e4aff072d Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Tue, 6 Aug 2024 15:09:26 +0800 Subject: [PATCH 12/26] add decorator list for client and operations --- .../emitter/sdk-context-options.ts | 25 ++++++ .../emitter/src/constants.ts | 17 ---- .../http-client-csharp/emitter/src/index.ts | 3 +- .../emitter/src/lib/client-model-builder.ts | 1 + .../emitter/src/lib/operation.ts | 2 + .../emitter/src/type/input-client.ts | 5 +- .../emitter/src/type/input-decorated-type.ts | 8 -- .../emitter/src/type/input-operation.ts | 5 +- .../emitter/src/type/input-parameter.ts | 5 +- .../emitter/src/type/input-type.ts | 5 +- .../test/Providers/ClientProviderTests.cs | 24 +++--- .../test/Providers/RestClientProviderTests.cs | 7 +- .../ScmMethodProviderCollectionTests.cs | 8 +- .../TestHelpers/TestClientTypeProvider.cs | 2 +- .../src/InputTypes/InputClient.cs | 6 +- .../src/InputTypes/InputDecoratedType.cs | 16 ---- .../src/InputTypes/InputDecoratorInfo.cs | 4 +- .../src/InputTypes/InputModelProperty.cs | 6 +- .../src/InputTypes/InputOperation.cs | 8 +- .../src/InputTypes/InputParameter.cs | 7 +- .../src/InputTypes/InputType.cs | 6 +- .../TypeSpecInputClientConverter.cs | 5 +- .../TypeSpecInputDecoratorInfoConverter.cs | 53 ++++++++++++ .../TypeSpecInputOperationConverter.cs | 5 +- .../TypeSpecInputParameterConverter.cs | 8 +- .../TypeSpecInputPrimitiveTypeConverter.cs | 7 +- .../TypeSpecInputUnionTypeConverter.cs | 5 +- .../Serialization/TypeSpecSerialization.cs | 2 + .../Serialization/Utf8JsonReaderExtensions.cs | 85 +++++++++++++++++++ .../test/InputLibraryVisitorTests.cs | 6 +- 30 files changed, 256 insertions(+), 90 deletions(-) create mode 100644 packages/http-client-csharp/emitter/sdk-context-options.ts delete mode 100644 packages/http-client-csharp/emitter/src/type/input-decorated-type.ts delete mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs diff --git a/packages/http-client-csharp/emitter/sdk-context-options.ts b/packages/http-client-csharp/emitter/sdk-context-options.ts new file mode 100644 index 00000000000..f7d166e3e78 --- /dev/null +++ b/packages/http-client-csharp/emitter/sdk-context-options.ts @@ -0,0 +1,25 @@ +import { CreateSdkContextOptions } from "@azure-tools/typespec-client-generator-core"; + +export let defaultSDKContextOptions: CreateSdkContextOptions = { + versioning: undefined, + additionalDecorators: [], +}; + +export function setSDKContextOptions(options: CreateSdkContextOptions) { + defaultSDKContextOptions = { + versioning: options.versioning ?? defaultSDKContextOptions.versioning, + additionalDecorators: appendAdditionalDecoratorsOfContextOptions(options), + }; +} + +function appendAdditionalDecoratorsOfContextOptions(options: CreateSdkContextOptions) { + if (options.additionalDecorators) { + if (defaultSDKContextOptions.additionalDecorators) { + return [...defaultSDKContextOptions.additionalDecorators, ...options.additionalDecorators]; + } else { + return options.additionalDecorators; + } + } else { + return defaultSDKContextOptions.additionalDecorators; + } +} diff --git a/packages/http-client-csharp/emitter/src/constants.ts b/packages/http-client-csharp/emitter/src/constants.ts index be7ee858391..254849d3819 100644 --- a/packages/http-client-csharp/emitter/src/constants.ts +++ b/packages/http-client-csharp/emitter/src/constants.ts @@ -1,26 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { CreateSdkContextOptions } from "@azure-tools/typespec-client-generator-core"; - export const projectedNameJsonKey = "json"; export const projectedNameCSharpKey = "csharp"; export const projectedNameClientKey = "client"; export const mockApiVersion = "0000-00-00"; export const tspOutputFileName = "tspCodeModel.json"; export const configurationFileName = "Configuration.json"; -export let createSDKContextoptions: CreateSdkContextOptions = {}; -export function getSDKContextOptions(): CreateSdkContextOptions { - return createSDKContextoptions; -} -export function setSDKContextOptions(options: CreateSdkContextOptions): void { - createSDKContextoptions = options; -} -export function addAdditionalDecorators(additionalDecorators: string[]): void { - if (!createSDKContextoptions.additionalDecorators) { - createSDKContextoptions.additionalDecorators = additionalDecorators; - } else { - createSDKContextoptions.additionalDecorators = - createSDKContextoptions.additionalDecorators.concat(additionalDecorators); - } -} diff --git a/packages/http-client-csharp/emitter/src/index.ts b/packages/http-client-csharp/emitter/src/index.ts index 00a0e420a44..b745005140b 100644 --- a/packages/http-client-csharp/emitter/src/index.ts +++ b/packages/http-client-csharp/emitter/src/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -export { addAdditionalDecorators, configurationFileName, tspOutputFileName } from "./constants.js"; +export { configurationFileName, tspOutputFileName } from "./constants.js"; export * from "./emitter.js"; export { createDiagnostic, getTracer, reportDiagnostic } from "./lib/lib.js"; export { LoggerLevel } from "./lib/log-level.js"; @@ -13,3 +13,4 @@ export { resolveOptions, resolveOutputFolder, } from "./options.js"; +export { setSDKContextOptions } from "./sdk-context-options.js"; diff --git a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts index 7401f8ac812..7e60a1fbccd 100644 --- a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts +++ b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts @@ -95,6 +95,7 @@ export function createModel(sdkContext: SdkContext): CodeMode Protocol: {}, Parent: parentNames.length > 0 ? parentNames[parentNames.length - 1] : undefined, Parameters: clientParameters, + Decorators: client.decorators, }; } diff --git a/packages/http-client-csharp/emitter/src/lib/operation.ts b/packages/http-client-csharp/emitter/src/lib/operation.ts index c6ae4215134..e4fddd45461 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation.ts @@ -99,6 +99,7 @@ export function fromSdkServiceMethod( Paging: loadOperationPaging(method), GenerateProtocolMethod: shouldGenerateProtocol(sdkContext, method.operation.__raw.operation), GenerateConvenienceMethod: generateConvenience, + Decorators: method.decorators, }; } @@ -202,6 +203,7 @@ function fromSdkHttpOperationParameter( IsRequired: !p.optional, Kind: getParameterKind(p, parameterType, isContentType, rootApiVersions.length > 0), DefaultValue: getParameterDefaultValue(p.clientDefaultValue, parameterType), + Decorators: p.decorators, } as InputParameter; } diff --git a/packages/http-client-csharp/emitter/src/type/input-client.ts b/packages/http-client-csharp/emitter/src/type/input-client.ts index 1ff23e989ec..df4a22358b3 100644 --- a/packages/http-client-csharp/emitter/src/type/input-client.ts +++ b/packages/http-client-csharp/emitter/src/type/input-client.ts @@ -1,16 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { InputDecoratedType } from "./input-decorated-type.js"; +import { DecoratorInfo } from "@azure-tools/typespec-client-generator-core"; import { InputOperation } from "./input-operation.js"; import { InputParameter } from "./input-parameter.js"; import { Protocols } from "./protocols.js"; -export interface InputClient extends InputDecoratedType { +export interface InputClient { Name: string; Description?: string; Operations: InputOperation[]; Protocol?: Protocols; Parent?: string; Parameters?: InputParameter[]; + Decorators?: DecoratorInfo[]; } diff --git a/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts b/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts deleted file mode 100644 index 2a12c6b6106..00000000000 --- a/packages/http-client-csharp/emitter/src/type/input-decorated-type.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -import { DecoratorInfo } from "@azure-tools/typespec-client-generator-core"; - -export interface InputDecoratedType { - Decorators?: DecoratorInfo[]; -} diff --git a/packages/http-client-csharp/emitter/src/type/input-operation.ts b/packages/http-client-csharp/emitter/src/type/input-operation.ts index d284c9de542..ab23e6f2b0b 100644 --- a/packages/http-client-csharp/emitter/src/type/input-operation.ts +++ b/packages/http-client-csharp/emitter/src/type/input-operation.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +import { DecoratorInfo } from "@azure-tools/typespec-client-generator-core"; import { BodyMediaType } from "./body-media-type.js"; -import { InputDecoratedType } from "./input-decorated-type.js"; import { InputParameter } from "./input-parameter.js"; import { OperationLongRunning } from "./operation-long-running.js"; import { OperationPaging } from "./operation-paging.js"; @@ -15,7 +15,7 @@ export interface Paging { NextPageMethod?: string; } -export interface InputOperation extends InputDecoratedType { +export interface InputOperation { Name: string; ResourceName?: string; Summary?: string; @@ -35,4 +35,5 @@ export interface InputOperation extends InputDecoratedType { Paging?: OperationPaging; GenerateProtocolMethod: boolean; GenerateConvenienceMethod: boolean; + Decorators?: DecoratorInfo[]; } diff --git a/packages/http-client-csharp/emitter/src/type/input-parameter.ts b/packages/http-client-csharp/emitter/src/type/input-parameter.ts index 6b7754eb35b..ff130bdcfe6 100644 --- a/packages/http-client-csharp/emitter/src/type/input-parameter.ts +++ b/packages/http-client-csharp/emitter/src/type/input-parameter.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +import { DecoratorInfo } from "@azure-tools/typespec-client-generator-core"; import { InputConstant } from "./input-constant.js"; -import { InputDecoratedType } from "./input-decorated-type.js"; import { InputOperationParameterKind } from "./input-operation-parameter-kind.js"; import { InputType } from "./input-type.js"; import { RequestLocation } from "./request-location.js"; //TODO: Define VirtualParameter for HLC export interface VirtualParameter {} -export interface InputParameter extends InputDecoratedType { +export interface InputParameter { Name: string; NameInRequest: string; Description?: string; @@ -28,4 +28,5 @@ export interface InputParameter extends InputDecoratedType { Explode: boolean; ArraySerializationDelimiter?: string; HeaderCollectionPrefix?: string; + Decorators?: DecoratorInfo[]; } diff --git a/packages/http-client-csharp/emitter/src/type/input-type.ts b/packages/http-client-csharp/emitter/src/type/input-type.ts index 19962e91ba6..0df51010d55 100644 --- a/packages/http-client-csharp/emitter/src/type/input-type.ts +++ b/packages/http-client-csharp/emitter/src/type/input-type.ts @@ -3,18 +3,19 @@ import { AccessFlags, + DecoratorInfo, SdkBuiltInKinds, UsageFlags, } from "@azure-tools/typespec-client-generator-core"; import { DateTimeKnownEncoding, DurationKnownEncoding } from "@typespec/compiler"; -import { InputDecoratedType } from "./input-decorated-type.js"; import { InputEnumTypeValue } from "./input-enum-type-value.js"; import { InputModelProperty } from "./input-model-property.js"; -interface InputTypeBase extends InputDecoratedType { +interface InputTypeBase { Kind: string; Description?: string; Deprecation?: string; + Decorators?: DecoratorInfo[]; } export type InputType = diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs index ec362fac70f..8721e72374c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs @@ -28,7 +28,7 @@ public void SetUp() [Test] public void TestBuildProperties() { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -48,7 +48,7 @@ public void TestBuildProperties() [TestCaseSource(nameof(BuildFieldsTestCases))] public void TestBuildFields(List inputParameters) { - var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null); + var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null, []); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -69,7 +69,7 @@ public void TestBuildFields(List inputParameters) [TestCaseSource(nameof(BuildConstructorsTestCases))] public void TestBuildConstructors_PrimaryConstructor(List inputParameters) { - var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null); + var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null, []); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -85,7 +85,7 @@ public void TestBuildConstructors_PrimaryConstructor(List inputP [TestCaseSource(nameof(BuildConstructorsTestCases))] public void TestBuildConstructors_SecondaryConstructor(List inputParameters) { - var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null); + var client = new InputClient("TestClient", "TestClient description", [], inputParameters, null, []); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -167,7 +167,7 @@ private void ValidateSecondaryConstructor( [TestCaseSource(nameof(EndpointParamInitializationValueTestCases))] public void EndpointInitializationValue(InputParameter endpointParameter, ValueExpression? expectedValue) { - var client = new InputClient("TestClient", "TestClient description", [], [endpointParameter], null); + var client = new InputClient("TestClient", "TestClient description", [], [endpointParameter], null, []); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -198,7 +198,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null), + isRequired: false, false, false, false, false, false, false, null, null, []), new( KnownParameters.Endpoint.Name, "endpoint description", @@ -207,7 +207,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, isEndpoint: true, false, false, null, null) + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) }); } } @@ -226,7 +226,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null), + isRequired: false, false, false, false, false, false, false, null, null, []), new( KnownParameters.Endpoint.Name, "endpoint description", @@ -235,7 +235,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: new InputConstant("someValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, isEndpoint: true, false, false, null, null) + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) }); // scenario where endpoint is required yield return new TestCaseData(new List @@ -248,7 +248,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: true, false, false, false, isEndpoint: true, false, false, null, null), + isRequired: true, false, false, false, isEndpoint: true, false, false, null, null, []), new( "optionalParam", "optionalParam description", @@ -257,7 +257,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null) + isRequired: false, false, false, false, false, false, false, null, null, []) }); } } @@ -274,7 +274,7 @@ private static IEnumerable EndpointParamInitializationValueTestCas RequestLocation.None, defaultValue: new InputConstant("mockValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, true, false, false, null, null), + isRequired: false, false, false, false, true, false, false, null, null, []), New.Instance(KnownParameters.Endpoint.Type, Literal("mockvalue"))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs index ec2240842fe..60b1cfa62dd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs @@ -104,7 +104,7 @@ public void ValidateProperties() accessibility: null, parameters: [ - new InputParameter("message", "message", "The message to create.", InputPrimitiveType.Boolean, RequestLocation.Body, null, InputOperationParameterKind.Method, true, false, false, false, false, false, false, null, null) + new InputParameter("message", "message", "The message to create.", InputPrimitiveType.Boolean, RequestLocation.Body, null, InputOperationParameterKind.Method, true, false, false, false, false, false, false, null, null, []) ], responses: [new OperationResponse([200], null, BodyMediaType.Json, [], false, ["application/json"])], httpMethod: "GET", @@ -117,9 +117,10 @@ public void ValidateProperties() longRunning: null, paging: null, generateProtocolMethod: true, - generateConvenienceMethod: true); + generateConvenienceMethod: true, + decorators: []); - private readonly static InputClient SingleOpInputClient = new InputClient("TestClient", "TestClient description", [BasicOperation], [], null); + private readonly static InputClient SingleOpInputClient = new InputClient("TestClient", "TestClient description", [BasicOperation], [], null, []); private static IEnumerable DefaultCSharpMethodCollectionTestCases => [ diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs index adb18f638be..527a71fee4b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs @@ -17,7 +17,7 @@ internal class ScmMethodProviderCollectionTests [TestCaseSource(nameof(DefaultCSharpMethodCollectionTestCases))] public void TestDefaultCSharpMethodCollection(InputOperation inputOperation) { - var inputClient = new InputClient("TestClient", "TestClient description", [inputOperation], [], null); + var inputClient = new InputClient("TestClient", "TestClient description", [inputOperation], [], null, []); MockHelpers.LoadMockPlugin( createCSharpTypeCore: (inputType) => new CSharpType(typeof(bool)), @@ -65,7 +65,8 @@ public static IEnumerable DefaultCSharpMethodCollectionTestCases false, false, null, - null) + null, + []) ], responses: [new OperationResponse([200], null, BodyMediaType.Json, [], false, ["application/json"])], httpMethod: "GET", @@ -78,7 +79,8 @@ public static IEnumerable DefaultCSharpMethodCollectionTestCases longRunning: null, paging: null, generateProtocolMethod: true, - generateConvenienceMethod: true + generateConvenienceMethod: true, + decorators: [] )); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs index 3d7fd266887..e38e1aafafe 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs @@ -10,7 +10,7 @@ internal class TestClientTypeProvider : ClientProvider { public static readonly ClientProvider Empty = new TestClientTypeProvider(); - public TestClientTypeProvider() : base(new InputClient("TestClient", "TestClient description", [], [], null)) + public TestClientTypeProvider() : base(new InputClient("TestClient", "TestClient description", [], [], null, [])) { } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs index 5efefb080dd..24a22b63188 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs @@ -11,22 +11,24 @@ public class InputClient private readonly string? _key; private IReadOnlyDictionary? _examples; - public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent) + public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent, IReadOnlyList decorators) { Name = name; Description = description; Operations = operations; Parameters = parameters; Parent = parent; + Decorators = decorators; } - public InputClient() : this(string.Empty, string.Empty, Array.Empty(), Array.Empty(), null) { } + public InputClient() : this(string.Empty, string.Empty, Array.Empty(), Array.Empty(), null, Array.Empty()) { } public string Name { get; internal set; } public string Description { get; internal set; } public IReadOnlyList Operations { get; internal set; } public IReadOnlyList Parameters { get; internal set; } public string? Parent { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } public string Key { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs deleted file mode 100644 index dd21cf48342..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratedType.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Collections.Generic; - -namespace Microsoft.Generator.CSharp.Input -{ - public class InputDecoratedType - { - public InputDecoratedType(IReadOnlyList decorators) - { - Decorators = decorators; - } - public IReadOnlyList Decorators { get; internal set; } - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs index 6c22c9f4967..031901a551d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs @@ -7,12 +7,12 @@ namespace Microsoft.Generator.CSharp.Input { public class InputDecoratorInfo { - public InputDecoratorInfo(string name, IReadOnlyDictionary arguments) + public InputDecoratorInfo(string name, IReadOnlyDictionary? arguments) { Name = name; Arguments = arguments; } public string Name { get; } - public IReadOnlyDictionary Arguments { get; } + public IReadOnlyDictionary? Arguments { get; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 49e0dc5f37f..5124ed75987 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -6,9 +6,9 @@ namespace Microsoft.Generator.CSharp.Input { - public class InputModelProperty : InputDecoratedType + public class InputModelProperty { - public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null) : base(decorators) + public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null) { Name = name; SerializedName = serializedName; @@ -18,6 +18,7 @@ public InputModelProperty(string name, string serializedName, string description IsReadOnly = isReadOnly; IsDiscriminator = isDiscriminator; FlattenedNames = flattenedNames ?? Array.Empty(); + Decorators = decorators; } public string Name { get; } @@ -28,5 +29,6 @@ public InputModelProperty(string name, string serializedName, string description public bool IsReadOnly { get; } public bool IsDiscriminator { get; } public IReadOnlyList FlattenedNames { get; } + public IReadOnlyList Decorators { get; internal set; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs index 609df92f352..84d4b7b159b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs @@ -29,7 +29,8 @@ public InputOperation( OperationLongRunning? longRunning, OperationPaging? paging, bool generateProtocolMethod, - bool generateConvenienceMethod) + bool generateConvenienceMethod, + IReadOnlyList decorators) { Name = name; ResourceName = resourceName; @@ -49,6 +50,7 @@ public InputOperation( Paging = paging; GenerateProtocolMethod = generateProtocolMethod; GenerateConvenienceMethod = generateConvenienceMethod; + Decorators = decorators; } public InputOperation() : this( @@ -69,7 +71,8 @@ public InputOperation() : this( longRunning: null, paging: null, generateProtocolMethod: true, - generateConvenienceMethod: false) + generateConvenienceMethod: false, + decorators: Array.Empty()) { } public string Name { get; internal set; } @@ -90,6 +93,7 @@ public InputOperation() : this( public OperationPaging? Paging { get; internal set; } public bool GenerateProtocolMethod { get; internal set; } public bool GenerateConvenienceMethod { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } private IReadOnlyDictionary? _examples; internal IReadOnlyDictionary Examples => _examples ??= EnsureExamples(); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs index 2cf23e001d7..d96776d81a4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public sealed class InputParameter @@ -21,7 +23,8 @@ public InputParameter( bool skipUrlEncoding, bool explode, string? arraySerializationDelimiter, - string? headerCollectionPrefix) + string? headerCollectionPrefix, + IReadOnlyList decorators) { Name = name; NameInRequest = nameInRequest; @@ -39,6 +42,7 @@ public InputParameter( Explode = explode; ArraySerializationDelimiter = arraySerializationDelimiter; HeaderCollectionPrefix = headerCollectionPrefix; + Decorators = decorators; } public string Name { get; } @@ -57,5 +61,6 @@ public InputParameter( public bool Explode { get; } public string? ArraySerializationDelimiter { get; } public string? HeaderCollectionPrefix { get; } + public IReadOnlyList Decorators { get; internal set; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index d4d6e46bf33..32e2fde1bda 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -8,18 +8,20 @@ namespace Microsoft.Generator.CSharp.Input /// /// Represents an input type to the generator. /// - public abstract class InputType : InputDecoratedType + public abstract class InputType { /// /// Construct a new instance /// /// The name of the input type. - protected InputType(string name, IReadOnlyList decorators) : base(decorators) + protected InputType(string name, IReadOnlyList decorators) { Name = name; + Decorators = decorators; } public string Name { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } internal InputType GetCollectionEquivalent(InputType inputType) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs index 4c608eb3c8e..a40a603f4c3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs @@ -38,6 +38,7 @@ public override void Write(Utf8JsonWriter writer, InputClient value, JsonSeriali string? description = null; IReadOnlyList? operations = null; IReadOnlyList? parameters = null; + IReadOnlyList? decorators = null; string? parent = null; while (reader.TokenType != JsonTokenType.EndObject) @@ -46,7 +47,8 @@ public override void Write(Utf8JsonWriter writer, InputClient value, JsonSeriali || reader.TryReadString(nameof(InputClient.Description), ref description) || reader.TryReadWithConverter(nameof(InputClient.Operations), options, ref operations) || reader.TryReadWithConverter(nameof(InputClient.Parameters), options, ref parameters) - || reader.TryReadString(nameof(InputClient.Parent), ref parent); + || reader.TryReadString(nameof(InputClient.Parent), ref parent) + || reader.TryReadWithConverter(nameof(InputClient.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -59,6 +61,7 @@ public override void Write(Utf8JsonWriter writer, InputClient value, JsonSeriali client.Operations = operations ?? Array.Empty(); client.Parameters = parameters ?? Array.Empty(); client.Parent = parent; + client.Decorators = decorators ?? Array.Empty(); return client; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs new file mode 100644 index 00000000000..7f0b2be1138 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; +using Microsoft.Generator.CSharp.Input; + +namespace AutoRest.CSharp.Common.Input +{ + internal class TypeSpecInputDecoratorInfoConverter : JsonConverter + { + private readonly TypeSpecReferenceHandler _referenceHandler; + + public TypeSpecInputDecoratorInfoConverter(TypeSpecReferenceHandler referenceHandler) + { + _referenceHandler = referenceHandler; + } + + public override InputDecoratorInfo? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + bool isFirstProperty = true; + string? id = null; + string? name = null; + IReadOnlyDictionary? arguments = null; + reader.Read(); + while (reader.TokenType != JsonTokenType.EndObject) + { + var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) + || reader.TryReadString(nameof(InputDecoratorInfo.Name).ToLower(), ref name) + || reader.TryReadStringObjectDictionary(nameof(InputDecoratorInfo.Arguments).ToLower(), ref arguments); + + if (!isKnownProperty) + { + reader.SkipProperty(); + } + } + reader.Read(); + + var decoratorInfo = new InputDecoratorInfo(name ?? throw new JsonException("InputDecoratorInfo must have name"), arguments); + + if (id != null) + { + _referenceHandler.CurrentResolver.AddReference(id, decoratorInfo); + } + return decoratorInfo; + } + + public override void Write(Utf8JsonWriter writer, InputDecoratorInfo value, JsonSerializerOptions options) + => throw new NotSupportedException("Writing not supported"); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs index 54c7dcf19b5..ce3ec3e772c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs @@ -54,6 +54,7 @@ public override void Write(Utf8JsonWriter writer, InputOperation value, JsonSeri OperationPaging? paging = null; bool generateProtocolMethod = false; bool generateConvenienceMethod = false; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { @@ -74,7 +75,8 @@ public override void Write(Utf8JsonWriter writer, InputOperation value, JsonSeri || reader.TryReadWithConverter(nameof(InputOperation.LongRunning), options, ref longRunning) || reader.TryReadWithConverter(nameof(InputOperation.Paging), options, ref paging) || reader.TryReadBoolean(nameof(InputOperation.GenerateProtocolMethod), ref generateProtocolMethod) - || reader.TryReadBoolean(nameof(InputOperation.GenerateConvenienceMethod), ref generateConvenienceMethod); + || reader.TryReadBoolean(nameof(InputOperation.GenerateConvenienceMethod), ref generateConvenienceMethod) + || reader.TryReadWithConverter(nameof(InputOperation.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -100,6 +102,7 @@ public override void Write(Utf8JsonWriter writer, InputOperation value, JsonSeri operation.Paging = paging; operation.GenerateProtocolMethod = generateProtocolMethod; operation.GenerateConvenienceMethod = generateConvenienceMethod; + operation.Decorators = decorators ?? Array.Empty(); return operation; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs index f7121c0a997..45df5f63f68 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -43,6 +44,7 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str bool explode = false; string? arraySerializationDelimiter = null; string? headerCollectionPrefix = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) @@ -61,7 +63,8 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str || reader.TryReadBoolean(nameof(InputParameter.SkipUrlEncoding), ref skipUrlEncoding) || reader.TryReadBoolean(nameof(InputParameter.Explode), ref explode) || reader.TryReadString(nameof(InputParameter.ArraySerializationDelimiter), ref arraySerializationDelimiter) - || reader.TryReadString(nameof(InputParameter.HeaderCollectionPrefix), ref headerCollectionPrefix); + || reader.TryReadString(nameof(InputParameter.HeaderCollectionPrefix), ref headerCollectionPrefix) + || reader.TryReadWithConverter(nameof(InputParameter.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -102,7 +105,8 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str skipUrlEncoding: skipUrlEncoding, explode: explode, arraySerializationDelimiter: arraySerializationDelimiter, - headerCollectionPrefix: headerCollectionPrefix); + headerCollectionPrefix: headerCollectionPrefix, + decorators: decorators ?? Array.Empty()); if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs index 0cfe43492d3..193b54b3c91 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -28,6 +29,7 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, string? crossLanguageDefinitionId = null; string? encode = null; InputPrimitiveType? baseType = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) @@ -35,7 +37,8 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, || reader.TryReadString(nameof(InputPrimitiveType.Name), ref name) || reader.TryReadString(nameof(InputPrimitiveType.CrossLanguageDefinitionId), ref crossLanguageDefinitionId) || reader.TryReadString(nameof(InputPrimitiveType.Encode), ref encode) - || reader.TryReadWithConverter(nameof(InputPrimitiveType.BaseType), options, ref baseType); + || reader.TryReadWithConverter(nameof(InputPrimitiveType.BaseType), options, ref baseType) + || reader.TryReadWithConverter(nameof(InputPrimitiveType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -52,7 +55,7 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, throw new JsonException($"Unknown primitive type kind: {kind}"); } - var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType); + var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType, decorators ?? Array.Empty()); if (id != null) { resolver.AddReference(id, primitiveType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs index 3ef1cfa336c..1c2e6e046a3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs @@ -36,10 +36,12 @@ public static InputUnionType CreateInputUnionType(ref Utf8JsonReader reader, str resolver.AddReference(id, union); IReadOnlyList? variantTypes = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadString(nameof(InputUnionType.Name), ref name) - || reader.TryReadWithConverter(nameof(InputUnionType.VariantTypes), options, ref variantTypes); + || reader.TryReadWithConverter(nameof(InputUnionType.VariantTypes), options, ref variantTypes) + || reader.TryReadWithConverter(nameof(InputUnionType.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -53,6 +55,7 @@ public static InputUnionType CreateInputUnionType(ref Utf8JsonReader reader, str throw new JsonException("Union must have a least one union type"); } union.VariantTypes = variantTypes; + union.Decorators = decorators ?? Array.Empty(); return union; } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecSerialization.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecSerialization.cs index 157abd4ad1f..268c3ab1df7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecSerialization.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecSerialization.cs @@ -3,6 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; +using AutoRest.CSharp.Common.Input; namespace Microsoft.Generator.CSharp.Input { @@ -39,6 +40,7 @@ public static class TypeSpecSerialization new TypeSpecInputDateTimeTypeConverter(referenceHandler), new TypeSpecInputDurationTypeConverter(referenceHandler), new TypeSpecInputAuthConverter(referenceHandler), + new TypeSpecInputDecoratorInfoConverter(referenceHandler), } }; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs index c053df718b0..77213f7bdbb 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -232,6 +233,90 @@ public static bool TryReadWithConverter(this ref Utf8JsonReader reader, strin return result; } + public static bool TryReadStringObjectDictionary(this ref Utf8JsonReader reader, string propertyName, ref IReadOnlyDictionary? value) + { + if (reader.GetString() != propertyName) + { + return false; + } + + if (reader.GetString() != propertyName) + { + return false; + } + + reader.Read(); + reader.Read(); + + var result = new Dictionary(); + while (reader.TokenType != JsonTokenType.EndObject) + { + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException(); + } + + string? argumentName = reader.GetString(); + if (argumentName is null) + { + throw new JsonException(); + } + + // skip $id property since the decorator argument should not be referenced anyway + if (argumentName == "$id") + { + reader.SkipProperty(); + continue; + } + + using var document = JsonDocument.ParseValue(ref reader); + var propertyValue = ConvertJsonElementToObject(document.RootElement); + result[argumentName] = propertyValue; + reader.Read(); + } + value = result; + return true; + } + + public static object? ConvertJsonElementToObject(JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.Object: + var result = new Dictionary(); + foreach (JsonProperty property in element.EnumerateObject()) + { + result.Add(property.Name, ConvertJsonElementToObject(property.Value)); + } + return result; + case JsonValueKind.Array: + return element.EnumerateArray().Select(s => ConvertJsonElementToObject(s)).ToArray(); + case JsonValueKind.String: + return element.GetString()!; + case JsonValueKind.Number: + if (element.TryGetInt32(out int integer)) + { + return integer; + } + else if (element.TryGetInt64(out long longNumber)) + { + return longNumber; + } + else if (element.TryGetSingle(out float floatNumber)) + { + return floatNumber; + } + else + { + return element.GetDouble(); + } + case JsonValueKind.True: + case JsonValueKind.False: + return element.GetBoolean(); + default: + return null; + } + } public static void SkipProperty(this ref Utf8JsonReader reader) { if (reader.TokenType != JsonTokenType.PropertyName) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs index 5fad25e9bd6..0413750af49 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs @@ -92,7 +92,7 @@ public void PreVisitsMethods() var param = new InputParameter("param", "name", "desc", new InputLiteralType(new InputPrimitiveType(InputPrimitiveTypeKind.String, "foo", "bar"), "bar", Array.Empty()), RequestLocation.Header, null, InputOperationParameterKind.Client, true, false, true, false, false, - false, false, null, null); + false, false, null, null, []); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", new List(), @@ -105,8 +105,8 @@ public void PreVisitsMethods() new InputOperation("testoperation", "name", "desc", null, null, new[] { param - }, Array.Empty(), "GET", BodyMediaType.Json, "http://example.com", "baz", null, null, true, null, null, true, true) - }, new []{param}, null) + }, Array.Empty(), "GET", BodyMediaType.Json, "http://example.com", "baz", null, null, true, null, null, true, true, []) + }, new []{param}, null, []) }, new InputAuth())); From 3f83ee09a123c8a58a5294777c7c14a89597faae Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 7 Aug 2024 14:04:34 +0800 Subject: [PATCH 13/26] don't pass down the decorator list when convert inputType to InputNullableType --- .../src/InputTypes/InputNullableType.cs | 4 ++++ .../src/InputTypes/InputType.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index 1c51ad24d07..430b458200e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -1,12 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input { public sealed class InputNullableType : InputType { + public InputNullableType(InputType type) : this(type, Array.Empty()) + { + } public InputNullableType(InputType type, IReadOnlyList decorators) : base("nullable", decorators) { Type = type; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index 32e2fde1bda..c613147f9dc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -46,7 +46,7 @@ internal InputType GetCollectionEquivalent(InputType inputType) public InputType WithNullable(bool isNullable) { if (isNullable) - return new InputNullableType(this, this.Decorators); + return new InputNullableType(this); return this; } public InputType GetImplementType() => this switch From 1931848197e6744a2ce701ff03e6cf1c49463c58 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 7 Aug 2024 14:24:13 +0800 Subject: [PATCH 14/26] remove the createSdkContextOptions --- packages/http-client-csharp/emitter/src/emitter.ts | 11 +++++++---- .../emitter/{ => src}/sdk-context-options.ts | 0 2 files changed, 7 insertions(+), 4 deletions(-) rename packages/http-client-csharp/emitter/{ => src}/sdk-context-options.ts (100%) diff --git a/packages/http-client-csharp/emitter/src/emitter.ts b/packages/http-client-csharp/emitter/src/emitter.ts index a0dfd99d519..9b8dbba1f39 100644 --- a/packages/http-client-csharp/emitter/src/emitter.ts +++ b/packages/http-client-csharp/emitter/src/emitter.ts @@ -16,11 +16,12 @@ import fs, { statSync } from "fs"; import { PreserveType, stringifyRefs } from "json-serialize-refs"; import { dirname } from "path"; import { fileURLToPath } from "url"; -import { configurationFileName, createSDKContextoptions, tspOutputFileName } from "./constants.js"; +import { configurationFileName, tspOutputFileName } from "./constants.js"; import { createModel } from "./lib/client-model-builder.js"; import { LoggerLevel } from "./lib/log-level.js"; import { Logger } from "./lib/logger.js"; import { NetEmitterOptions, resolveOptions, resolveOutputFolder } from "./options.js"; +import { defaultSDKContextOptions } from "./sdk-context-options.js"; import { Configuration } from "./type/configuration.js"; /** @@ -53,9 +54,11 @@ export async function $onEmit(context: EmitContext) { if (!program.compilerOptions.noEmit && !program.hasError()) { // Write out the dotnet model to the output path - const sdkContext = await createSdkContext(context, "@typespec/http-client-csharp", { - ...createSDKContextoptions, - }); + const sdkContext = await createSdkContext( + context, + "@typespec/http-client-csharp", + defaultSDKContextOptions + ); const root = createModel(sdkContext); if ( context.program.diagnostics.length > 0 && diff --git a/packages/http-client-csharp/emitter/sdk-context-options.ts b/packages/http-client-csharp/emitter/src/sdk-context-options.ts similarity index 100% rename from packages/http-client-csharp/emitter/sdk-context-options.ts rename to packages/http-client-csharp/emitter/src/sdk-context-options.ts From b97ad40de28e93038b93319ce3d5b141147439d6 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 7 Aug 2024 17:25:06 +0800 Subject: [PATCH 15/26] update test --- .../Providers/ClientOptionsProviderTests.cs | 13 ++-- .../src/InputTypes/InputDecoratorInfo.cs | 5 +- .../TypeSpecInputDecoratorInfoConverter.cs | 4 +- .../Serialization/Utf8JsonReaderExtensions.cs | 76 ++----------------- .../Microsoft.Generator.CSharp.Input.csproj | 4 +- .../test/Providers/EnumProviderTests.cs | 3 +- .../test/TypeFactoryTests.cs | 3 +- 7 files changed, 26 insertions(+), 82 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs index 1d72538fea4..46192292b61 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs @@ -40,7 +40,8 @@ public void SetUp() InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.Int64, enumValues, - false); + false, + []); MockHelpers.LoadMockPlugin( apiVersions: () => apiVersions, @@ -55,7 +56,7 @@ public void SetUp() [Test] public void TestImplements() { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -71,7 +72,7 @@ public void TestImplements() [TestCase(false)] public void TestFields(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -94,7 +95,7 @@ public void TestFields(bool containsApiVersions) [TestCase(false)] public void TestNestedTypes(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -122,7 +123,7 @@ public void TestNestedTypes(bool containsApiVersions) [TestCase(false)] public void TestConstructors(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -151,7 +152,7 @@ public void TestConstructors(bool containsApiVersions) [TestCase(false)] public void TestProperties(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null); + var client = new InputClient("TestClient", "TestClient description", [], [], null, []); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs index 031901a551d..7494f0d94bf 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDecoratorInfo.cs @@ -1,18 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input { public class InputDecoratorInfo { - public InputDecoratorInfo(string name, IReadOnlyDictionary? arguments) + public InputDecoratorInfo(string name, IReadOnlyDictionary? arguments) { Name = name; Arguments = arguments; } public string Name { get; } - public IReadOnlyDictionary? Arguments { get; } + public IReadOnlyDictionary? Arguments { get; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs index 7f0b2be1138..5d02035ae32 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs @@ -23,13 +23,13 @@ public TypeSpecInputDecoratorInfoConverter(TypeSpecReferenceHandler referenceHan bool isFirstProperty = true; string? id = null; string? name = null; - IReadOnlyDictionary? arguments = null; + IReadOnlyDictionary? arguments = null; reader.Read(); while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputDecoratorInfo.Name).ToLower(), ref name) - || reader.TryReadStringObjectDictionary(nameof(InputDecoratorInfo.Arguments).ToLower(), ref arguments); + || reader.TryReadStringBinaryDataDictionary(nameof(InputDecoratorInfo.Arguments).ToLower(), ref arguments); if (!isKnownProperty) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs index 77213f7bdbb..79a69c761c8 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/Utf8JsonReaderExtensions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -233,11 +232,11 @@ public static bool TryReadWithConverter(this ref Utf8JsonReader reader, strin return result; } - public static bool TryReadStringObjectDictionary(this ref Utf8JsonReader reader, string propertyName, ref IReadOnlyDictionary? value) + public static bool TryReadStringBinaryDataDictionary(this ref Utf8JsonReader reader, string propertyName, ref IReadOnlyDictionary? value) { - if (reader.GetString() != propertyName) + if (reader.TokenType != JsonTokenType.PropertyName) { - return false; + throw new JsonException(); } if (reader.GetString() != propertyName) @@ -246,77 +245,16 @@ public static bool TryReadStringObjectDictionary(this ref Utf8JsonReader reader, } reader.Read(); - reader.Read(); - - var result = new Dictionary(); - while (reader.TokenType != JsonTokenType.EndObject) + using var document = JsonDocument.ParseValue(ref reader); + var result = new Dictionary(); + foreach (JsonProperty property in document.RootElement.EnumerateObject()) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException(); - } - - string? argumentName = reader.GetString(); - if (argumentName is null) - { - throw new JsonException(); - } - - // skip $id property since the decorator argument should not be referenced anyway - if (argumentName == "$id") - { - reader.SkipProperty(); - continue; - } - - using var document = JsonDocument.ParseValue(ref reader); - var propertyValue = ConvertJsonElementToObject(document.RootElement); - result[argumentName] = propertyValue; - reader.Read(); + result.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } value = result; return true; } - public static object? ConvertJsonElementToObject(JsonElement element) - { - switch (element.ValueKind) - { - case JsonValueKind.Object: - var result = new Dictionary(); - foreach (JsonProperty property in element.EnumerateObject()) - { - result.Add(property.Name, ConvertJsonElementToObject(property.Value)); - } - return result; - case JsonValueKind.Array: - return element.EnumerateArray().Select(s => ConvertJsonElementToObject(s)).ToArray(); - case JsonValueKind.String: - return element.GetString()!; - case JsonValueKind.Number: - if (element.TryGetInt32(out int integer)) - { - return integer; - } - else if (element.TryGetInt64(out long longNumber)) - { - return longNumber; - } - else if (element.TryGetSingle(out float floatNumber)) - { - return floatNumber; - } - else - { - return element.GetDouble(); - } - case JsonValueKind.True: - case JsonValueKind.False: - return element.GetBoolean(); - default: - return null; - } - } public static void SkipProperty(this ref Utf8JsonReader reader) { if (reader.TokenType != JsonTokenType.PropertyName) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/Microsoft.Generator.CSharp.Input.csproj b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/Microsoft.Generator.CSharp.Input.csproj index 9a260d9cae2..a79d5ddd035 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/Microsoft.Generator.CSharp.Input.csproj +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/Microsoft.Generator.CSharp.Input.csproj @@ -4,5 +4,7 @@ Microsoft.Generator.CSharp.Input 1.0.0-beta.1 - + + + diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index e4f2d269f7c..1ecb0327e59 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -6,6 +6,7 @@ using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Snippets; using NUnit.Framework; namespace Microsoft.Generator.CSharp.Tests.Providers @@ -78,7 +79,7 @@ public void BuildEnumType_ValidateApiVersionEnum() MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); string[] apiVersions = ["2024-07-16", "2024-07-17"]; - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.String, [new InputEnumTypeValue(apiVersions[0], 1, null), new InputEnumTypeValue(apiVersions[1], 2, null)], false); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.String, [new InputEnumTypeValue(apiVersions[0], 1, null), new InputEnumTypeValue(apiVersions[1], 2, null)], false, []); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs index 91e45cabfa7..b89489fc419 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs @@ -140,7 +140,8 @@ public void CreateEnum_WithDeclaringType() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false); + false, + []); var declaringType = new Mock().Object; var expected = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input, declaringType); var actual = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input, declaringType); From ae7164218c769ec210d8f569609c9debe10583d1 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Thu, 8 Aug 2024 09:54:53 +0800 Subject: [PATCH 16/26] resolve test failure --- .../test/Providers/ClientProviderTests.cs | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs index b2dfeea6946..a9f8137b9ad 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviderTests.cs @@ -232,7 +232,46 @@ public static IEnumerable BuildFieldsTestCases defaultValue: null, InputOperationParameterKind.Client, isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) - }); + }, false); + yield return new TestCaseData(new List + { + new( + "optionalParam", + "optionalParam description", + "optionalParam", + InputPrimitiveType.String, + RequestLocation.None, + defaultValue: new InputConstant("someValue", InputPrimitiveType.String), + InputOperationParameterKind.Client, + isRequired: false, false, false, false, false, false, false, null, null, []), + new( + "optionalParam2", + "optionalParam description", + "optionalParam2", + InputPrimitiveType.String, + RequestLocation.None, + defaultValue: new InputConstant("someValue", InputPrimitiveType.String), + InputOperationParameterKind.Client, + isRequired: false, false, false, false, false, false, false, null, null, []), + new( + "optionalParam3", + "optionalParam description", + "optionalParam3", + InputPrimitiveType.Int64, + RequestLocation.None, + defaultValue: new InputConstant(2, InputPrimitiveType.Int64), + InputOperationParameterKind.Client, + isRequired: false, false, false, false, false, false, false, null, null, []), + new( + KnownParameters.Endpoint.Name, + "endpoint description", + KnownParameters.Endpoint.Name, + InputPrimitiveType.String, + RequestLocation.None, + defaultValue: null, + InputOperationParameterKind.Client, + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) + }, true); } } From b682f28df10029fa87b460161680832cdc619534 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 9 Aug 2024 13:57:23 +0800 Subject: [PATCH 17/26] add unit test --- .../test/Unit/emit-decorator-list.test.ts | 163 ++++++++++++++++++ .../emitter/test/Unit/utils/test-util.ts | 11 +- 2 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 packages/http-client-csharp/emitter/test/Unit/emit-decorator-list.test.ts diff --git a/packages/http-client-csharp/emitter/test/Unit/emit-decorator-list.test.ts b/packages/http-client-csharp/emitter/test/Unit/emit-decorator-list.test.ts new file mode 100644 index 00000000000..3e7a86f4242 --- /dev/null +++ b/packages/http-client-csharp/emitter/test/Unit/emit-decorator-list.test.ts @@ -0,0 +1,163 @@ +import { TestHost } from "@typespec/compiler/testing"; +import { deepStrictEqual, strictEqual } from "assert"; +import { beforeEach, describe, it } from "vitest"; +import { createModel } from "../../src/lib/client-model-builder.js"; +import { + createEmitterContext, + createEmitterTestHost, + createNetSdkContext, + typeSpecCompile, +} from "./utils/test-util.js"; + +describe("Test emitting decorator list", () => { + let runner: TestHost; + + beforeEach(async () => { + runner = await createEmitterTestHost(); + }); + + it("emit decorator list on a client", async () => { + const program = await typeSpecCompile( + ` + @clientName("CsharpBookClient") + interface BookClient { + op test(): void; + } + `, + runner, + { IsTCGCNeeded: true, IsXmlNeeded: true } + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context, { + additionalDecorators: ["Azure\\.ClientGenerator\\.Core\\.@clientName"], + }); + const root = createModel(sdkContext); + const clients = root.Clients; + strictEqual(clients.length, 2); + deepStrictEqual(clients[1].Decorators, [ + { + name: "Azure.ClientGenerator.Core.@clientName", + arguments: { + rename: "CsharpBookClient", + }, + }, + ]); + }); + + it("emit decorator list on a operation", async () => { + const program = await typeSpecCompile( + ` + model Book { + content: string; + } + @clientName("ClientTestOperation") + op test(): Book; + `, + runner, + { IsTCGCNeeded: true, IsXmlNeeded: true } + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context, { + additionalDecorators: ["Azure\\.ClientGenerator\\.Core\\.@clientName"], + }); + const root = createModel(sdkContext); + const operations = root.Clients[0].Operations; + strictEqual(operations.length, 1); + deepStrictEqual(operations[0].Decorators, [ + { + name: "Azure.ClientGenerator.Core.@clientName", + arguments: { + rename: "ClientTestOperation", + }, + }, + ]); + }); + + it("emit decorator list on a model", async () => { + const program = await typeSpecCompile( + ` + @clientName("ClientBook") + model Book { + content: string; + } + + op test(): Book; + `, + runner, + { IsTCGCNeeded: true, IsXmlNeeded: true } + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context, { + additionalDecorators: ["Azure\\.ClientGenerator\\.Core\\.@clientName"], + }); + const root = createModel(sdkContext); + const models = root.Models; + strictEqual(models.length, 1); + deepStrictEqual(models[0].Decorators, [ + { + name: "Azure.ClientGenerator.Core.@clientName", + arguments: { + rename: "ClientBook", + }, + }, + ]); + }); + + it("emit decorator list on a model property", async () => { + const program = await typeSpecCompile( + ` + model Book { + @clientName("ClientContent") + content: string; + } + + op test(): Book; + `, + runner, + { IsTCGCNeeded: true, IsXmlNeeded: true } + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context, { + additionalDecorators: ["Azure\\.ClientGenerator\\.Core\\.@clientName"], + }); + const root = createModel(sdkContext); + const models = root.Models; + strictEqual(models.length, 1); + deepStrictEqual(models[0].Properties[0].Decorators, [ + { + name: "Azure.ClientGenerator.Core.@clientName", + arguments: { + rename: "ClientContent", + }, + }, + ]); + }); + + it("emit decorator list on a parameter", async () => { + const program = await typeSpecCompile( + ` + @clientName("ClientTestOperation") + op test(@clientName("ClientId") @header id: string): void; + `, + runner, + { IsTCGCNeeded: true, IsXmlNeeded: true } + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context, { + additionalDecorators: ["Azure\\.ClientGenerator\\.Core\\.@clientName"], + }); + const root = createModel(sdkContext); + const operations = root.Clients[0].Operations; + strictEqual(operations.length, 1); + const idParameters = operations[0].Parameters.filter((p) => p.Name === "ClientId"); + strictEqual(idParameters.length, 1); + deepStrictEqual(idParameters[0].Decorators, [ + { + name: "Azure.ClientGenerator.Core.@clientName", + arguments: { + rename: "ClientId", + }, + }, + ]); + }); +}); diff --git a/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts b/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts index 2cb2fec4262..0d9a185c10b 100644 --- a/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts +++ b/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts @@ -1,5 +1,9 @@ import { AzureCoreTestLibrary } from "@azure-tools/typespec-azure-core/testing"; -import { createSdkContext, SdkContext } from "@azure-tools/typespec-client-generator-core"; +import { + createSdkContext, + CreateSdkContextOptions, + SdkContext, +} from "@azure-tools/typespec-client-generator-core"; import { SdkTestLibrary } from "@azure-tools/typespec-client-generator-core/testing"; import { CompilerOptions, @@ -131,8 +135,9 @@ export function navigateModels( /* We always need to pass in the emitter name now that it is required so making a helper to do this. */ export async function createNetSdkContext( - program: EmitContext + program: EmitContext, + sdkContextOptions: CreateSdkContextOptions = {} ): Promise> { Logger.initialize(program.program, LoggerLevel.INFO); - return await createSdkContext(program, "@typespec/http-client-csharp"); + return await createSdkContext(program, "@typespec/http-client-csharp", sdkContextOptions); } From 015e3891d0ae94e4dd186bb49cb4849d4808506a Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 9 Aug 2024 15:35:45 +0800 Subject: [PATCH 18/26] set default value for decorators parameter in constructor --- .../JsonModelCoreTests.cs | 3 +- .../MrwSerializationTypeDefinitionTests.cs | 10 ++-- .../src/InputTypes/InputArrayType.cs | 2 +- .../src/InputTypes/InputClient.cs | 4 +- .../src/InputTypes/InputDateTimeType.cs | 2 +- .../src/InputTypes/InputDictionaryType.cs | 2 +- .../src/InputTypes/InputDurationType.cs | 2 +- .../src/InputTypes/InputEnumType.cs | 2 +- .../src/InputTypes/InputLiteralType.cs | 2 +- .../src/InputTypes/InputModelProperty.cs | 6 +-- .../src/InputTypes/InputModelType.cs | 2 +- .../src/InputTypes/InputNullableType.cs | 5 +- .../src/InputTypes/InputOperation.cs | 4 +- .../src/InputTypes/InputParameter.cs | 4 +- .../src/InputTypes/InputPrimitiveType.cs | 16 ++---- .../src/InputTypes/InputType.cs | 4 +- .../src/InputTypes/InputUnionType.cs | 2 +- .../TypeSpecInputArrayTypeConverter.cs | 2 +- .../TypeSpecInputDateTimeTypeConverter.cs | 2 +- .../TypeSpecInputDictionaryTypeConverter.cs | 2 +- .../TypeSpecInputDurationTypeConverter.cs | 2 +- .../TypeSpecInputEnumTypeConverter.cs | 2 +- .../TypeSpecInputLiteralTypeConverter.cs | 2 +- .../TypeSpecInputModelPropertyConverter.cs | 2 +- .../TypeSpecInputNullableTypeConverter.cs | 2 +- .../TypeSpecInputParameterConverter.cs | 2 +- .../TypeSpecInputPrimitiveTypeConverter.cs | 2 +- .../perf/CodeWriterBenchmark.cs | 4 +- .../Expressions/NewInstanceExpressionTests.cs | 2 +- .../test/InputLibraryVisitorTests.cs | 14 ++--- .../test/Providers/EnumProviderTests.cs | 14 ++--- .../test/Providers/ModelProviderTests.cs | 52 +++++++++---------- .../Providers/PropertyDescriptionTests.cs | 12 ++--- .../test/Providers/PropertyProviderTests.cs | 24 ++++----- .../test/TypeFactoryTests.cs | 17 +++--- .../test/Writers/TypeProviderWriterTests.cs | 12 ++--- 36 files changed, 109 insertions(+), 134 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index df0c2114d6f..0ef88a1d91a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -81,8 +81,7 @@ public void SnakeCaseSerializedName() InputPrimitiveType.String, true, false, - false, - Array.Empty()); + false); var inputModel = new InputModelType( "TestModel", "TestModel", diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index 36647540b73..495b5b60237 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -509,13 +509,13 @@ public void TestBuildConstructor_ValidateConstructors() { var properties = new List { - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), - new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, []), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false, []), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), + new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String), true, false, false), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String), true, false, false), }; - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var ctors = serialization.Constructors; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs index f3b0ce2ad2b..629c933046c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs @@ -14,7 +14,7 @@ public sealed class InputArrayType : InputType /// The name of the list type. /// The crossLanguageDefinitionId of the list type. For a builtin array, it should be `TypeSpec.Array`. /// The element's . - public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType, IReadOnlyList decorators) : base(name, decorators) + public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType, IReadOnlyList? decorators = null) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs index 24a22b63188..895c38e6eb1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs @@ -11,14 +11,14 @@ public class InputClient private readonly string? _key; private IReadOnlyDictionary? _examples; - public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent, IReadOnlyList decorators) + public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent, IReadOnlyList? decorators = null) { Name = name; Description = description; Operations = operations; Parameters = parameters; Parent = parent; - Decorators = decorators; + Decorators = decorators ?? []; } public InputClient() : this(string.Empty, string.Empty, Array.Empty(), Array.Empty(), null, Array.Empty()) { } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs index 3314025fcc7..08676ad5f32 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputDateTimeType : InputType { - public InputDateTimeType(DateTimeKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, IReadOnlyList decorators, InputDateTimeType? baseType = null) : base(name, decorators) + public InputDateTimeType(DateTimeKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDateTimeType? baseType = null, IReadOnlyList? decorators = null) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Encode = encode; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs index 80117b27ead..cb70db74402 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs @@ -15,7 +15,7 @@ public sealed class InputDictionaryType : InputType /// The key's . /// The value's . /// Flag used to determine if the input dictionary type is nullable. - public InputDictionaryType(string name, InputType keyType, InputType valueType, IReadOnlyList decorators) : base(name, decorators) + public InputDictionaryType(string name, InputType keyType, InputType valueType, IReadOnlyList? decorators = null) : base(name, decorators) { KeyType = keyType; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs index d075781e90f..783f39ac556 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputDurationType : InputType { - public InputDurationType(DurationKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDurationType? baseType, IReadOnlyList decorators) : base(name, decorators) + public InputDurationType(DurationKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDurationType? baseType, IReadOnlyList? decorators = null) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Encode = encode; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs index 5aeb6aac1cf..e902a916585 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputEnumType : InputType { - public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible, IReadOnlyList decorators) + public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible, IReadOnlyList? decorators = null) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs index e4eba7e2313..b46bfd04576 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public sealed class InputLiteralType : InputType { - public InputLiteralType(InputType valueType, object value, IReadOnlyList decorators) : base("Literal", decorators) + public InputLiteralType(InputType valueType, object value, IReadOnlyList? decorators = null) : base("Literal", decorators) { ValueType = valueType; Value = value; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 5124ed75987..36aa233a088 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -8,7 +8,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputModelProperty { - public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList decorators, IReadOnlyList? flattenedNames = null) + public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList? flattenedNames = null, IReadOnlyList? decorators = null) { Name = name; SerializedName = serializedName; @@ -17,8 +17,8 @@ public InputModelProperty(string name, string serializedName, string description IsRequired = isRequired; IsReadOnly = isReadOnly; IsDiscriminator = isDiscriminator; - FlattenedNames = flattenedNames ?? Array.Empty(); - Decorators = decorators; + FlattenedNames = flattenedNames ?? []; + Decorators = decorators ?? []; } public string Name { get; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index da90380f385..90b51d3c97b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -10,7 +10,7 @@ namespace Microsoft.Generator.CSharp.Input public class InputModelType : InputType { // TODO: Follow up issue https://github.com/microsoft/typespec/issues/3619. After https://github.com/Azure/typespec-azure/pull/966 is completed, update this type and remove the "modelAsStruct" parameter. - public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct, IReadOnlyList decorators) + public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct, IReadOnlyList? decorators = null) : base(name, decorators) { CrossLanguageDefinitionId = crossLanguageDefinitionId; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index 430b458200e..285892516b9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -8,10 +8,7 @@ namespace Microsoft.Generator.CSharp.Input { public sealed class InputNullableType : InputType { - public InputNullableType(InputType type) : this(type, Array.Empty()) - { - } - public InputNullableType(InputType type, IReadOnlyList decorators) : base("nullable", decorators) + public InputNullableType(InputType type, IReadOnlyList? decorators = null) : base("nullable", decorators) { Type = type; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs index 58fa9d7f8d2..4cbf95cdf7f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs @@ -31,7 +31,7 @@ public InputOperation( bool generateProtocolMethod, bool generateConvenienceMethod, string crossLanguageDefinitionId, - IReadOnlyList decorators) + IReadOnlyList? decorators = null) { Name = name; ResourceName = resourceName; @@ -52,7 +52,7 @@ public InputOperation( GenerateProtocolMethod = generateProtocolMethod; GenerateConvenienceMethod = generateConvenienceMethod; CrossLanguageDefinitionId = crossLanguageDefinitionId; - Decorators = decorators; + Decorators = decorators ?? []; } public InputOperation() : this( diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs index d96776d81a4..71fdbc84101 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs @@ -24,7 +24,7 @@ public InputParameter( bool explode, string? arraySerializationDelimiter, string? headerCollectionPrefix, - IReadOnlyList decorators) + IReadOnlyList? decorators = null) { Name = name; NameInRequest = nameInRequest; @@ -42,7 +42,7 @@ public InputParameter( Explode = explode; ArraySerializationDelimiter = arraySerializationDelimiter; HeaderCollectionPrefix = headerCollectionPrefix; - Decorators = decorators; + Decorators = decorators ?? []; } public string Name { get; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs index df18be801a9..b99620f48ac 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs @@ -8,28 +8,18 @@ namespace Microsoft.Generator.CSharp.Input { public sealed class InputPrimitiveType : InputType { - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId) : this(kind, name, crossLanguageDefinitionId, Array.Empty()) - { - } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, IReadOnlyList decorators) : base(name, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, IReadOnlyList? decorators = null) : base(name, decorators) { Kind = kind; CrossLanguageDefinitionId = crossLanguageDefinitionId; } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode) : this(kind, name, crossLanguageDefinitionId, encode, Array.Empty()) - { - } - - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, IReadOnlyList decorators) : this(kind, name, crossLanguageDefinitionId, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, IReadOnlyList? decorators = null) : this(kind, name, crossLanguageDefinitionId, decorators) { Encode = encode; } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, InputPrimitiveType? baseType) : this(kind, name, crossLanguageDefinitionId, encode, baseType, Array.Empty()) - { - } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, InputPrimitiveType? baseType, IReadOnlyList decorators) : this(kind, name, crossLanguageDefinitionId, encode, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, InputPrimitiveType? baseType, IReadOnlyList? decorators = null) : this(kind, name, crossLanguageDefinitionId, encode, decorators) { BaseType = baseType; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index c613147f9dc..715961e750c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -14,10 +14,10 @@ public abstract class InputType /// Construct a new instance /// /// The name of the input type. - protected InputType(string name, IReadOnlyList decorators) + protected InputType(string name, IReadOnlyList? decorators = null) { Name = name; - Decorators = decorators; + Decorators = decorators ?? []; } public string Name { get; internal set; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs index 84ac6180a16..83f554fb4bf 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputUnionType : InputType { - public InputUnionType(string name, IReadOnlyList variantTypes, IReadOnlyList decorators) : base(name, decorators) + public InputUnionType(string name, IReadOnlyList variantTypes, IReadOnlyList? decorators = null) : base(name, decorators) { VariantTypes = variantTypes; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs index 30da5e10e2c..f3150267d08 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs @@ -44,7 +44,7 @@ public static InputArrayType CreateListType(ref Utf8JsonReader reader, string? i } valueType = valueType ?? throw new JsonException("List must have element type"); - var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType, decorators ?? Array.Empty()); + var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType, decorators); if (id != null) { resolver.AddReference(id, listType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs index e589a6cdc6a..838a34b906e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDateTimeType CreateDateTimeType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("DateTime type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, decorators ?? Array.Empty(), baseType) + ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType, decorators) : throw new JsonException($"Encoding of DateTime type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs index bf9d178aef1..edd0c86b56b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs @@ -45,7 +45,7 @@ public static InputDictionaryType CreateDictionaryType(ref Utf8JsonReader reader keyType = keyType ?? throw new JsonException("Dictionary must have key type"); valueType = valueType ?? throw new JsonException("Dictionary must have value type"); - var dictType = new InputDictionaryType("Dictionary", keyType, valueType, decorators ?? Array.Empty()); + var dictType = new InputDictionaryType("Dictionary", keyType, valueType, decorators); if (id != null) { resolver.AddReference(id, dictType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs index fe224cd0038..428f3027129 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("Duration type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType, decorators ?? Array.Empty()) + ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType, decorators) : throw new JsonException($"Encoding of Duration type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs index 7b474406680..4da775f941d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs @@ -78,7 +78,7 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id throw new JsonException("The ValueType of an EnumType must be a primitive type."); } - var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable, decorators ?? Array.Empty()); + var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable, decorators); if (id != null) { resolver.AddReference(id, enumType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs index ba486230d9f..84e0021dd25 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs @@ -54,7 +54,7 @@ public static InputLiteralType CreateInputLiteralType(ref Utf8JsonReader reader, value = value ?? throw new JsonException("InputConstant must have value"); - var literalType = new InputLiteralType(type, value, decorators ?? Array.Empty()); + var literalType = new InputLiteralType(type, value, decorators); if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index 1070ab127b8..ee354968d1c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -60,7 +60,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read // description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, decorators ?? Array.Empty(), flattenedNames); + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames, decorators); if (id != null) { resolver.AddReference(id, property); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 11945d002e0..4d5690517c6 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -42,7 +42,7 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st valueType = valueType ?? throw new JsonException("InputNullableType must have value type"); - var nullableType = new InputNullableType(valueType, decorators ?? Array.Empty()); + var nullableType = new InputNullableType(valueType, decorators); if (id != null) { resolver.AddReference(id, nullableType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs index d7578202236..028dcd5b572 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs @@ -110,7 +110,7 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str explode: explode, arraySerializationDelimiter: arraySerializationDelimiter, headerCollectionPrefix: headerCollectionPrefix, - decorators: decorators ?? Array.Empty()); + decorators: decorators); if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs index 193b54b3c91..eb5614ca73a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs @@ -55,7 +55,7 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, throw new JsonException($"Unknown primitive type kind: {kind}"); } - var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType, decorators ?? Array.Empty()); + var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType, decorators); if (id != null) { resolver.AddReference(id, primitiveType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs index 6368cd43b02..d0c992d5e6f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/perf/CodeWriterBenchmark.cs @@ -19,9 +19,9 @@ public CodeWriterBenchmark() PluginInitializer.Initialize(); var properties = new[] { - new InputModelProperty("MyProperty", "myProperty", "The property of mine", InputPrimitiveType.Int32, true, false, false, Array.Empty()) + new InputModelProperty("MyProperty", "myProperty", "The property of mine", InputPrimitiveType.Int32, true, false, false) }; - var inputModel = new InputModelType("MyModel", string.Empty, null, null, "Test model", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("MyModel", string.Empty, null, null, "Test model", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); var modelProvider = new ModelProvider(inputModel); _writer = new TypeProviderWriter(modelProvider); } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs index dd6543b3912..d772007f2fd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs @@ -45,7 +45,7 @@ public void ValidateAnonymousWithPropertiesSingleLine() [Test] public void ValidateNullableValueType() { - InputEnumType enumType = new InputEnumType("MyEnum", "MyEnum", "public", null, "MyEnum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "one", null), new InputEnumTypeValue("Two", "two", null)], true, Array.Empty()); + InputEnumType enumType = new InputEnumType("MyEnum", "MyEnum", "public", null, "MyEnum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "one", null), new InputEnumTypeValue("Two", "two", null)], true); var provider = CodeModelPlugin.Instance.TypeFactory.CreateEnum(enumType); Assert.NotNull(provider); var expr = New.Instance(provider!.Type, Literal("three")); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs index e2ea2593f2d..598f26f0058 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs @@ -33,7 +33,7 @@ public void PreVisitsProperties() { _mockPlugin.Object.AddVisitor(_mockVisitor.Object); var inputModelProperty = - new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false, Array.Empty()); + new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel = new InputModelType("foo", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false, []); @@ -58,9 +58,9 @@ public void PreVisitsEnum() var inputEnum = new InputEnumType("enum", "id", "desc", null, "description", InputModelTypeUsage.Input, InputPrimitiveType.Int32, new[] { new InputEnumTypeValue("value", 1, "desc") - }, false, Array.Empty()); + }, false); var inputModelProperty = - new InputModelProperty("prop1", "prop1", "string", inputEnum, true, true, false, Array.Empty()); + new InputModelProperty("prop1", "prop1", "string", inputEnum, true, true, false); var inputModel = new InputModelType("foo", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false, []); @@ -83,11 +83,11 @@ public void PreVisitsEnum() public void RemovedInputModelCausesExceptionWhenReferencedInDifferentModel() { var inputModel1Property = - new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false, Array.Empty()); + new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel1 = new InputModelType("Model1", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false, []); - var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false, Array.Empty()); + var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false); var inputModel2 = new InputModelType("Model2", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false, []); @@ -109,11 +109,11 @@ public void RemovedInputModelCausesExceptionWhenReferencedInDifferentModel() public void CanCleanUpRemovedReferencesToRemovedModels() { var inputModel1Property = - new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false, Array.Empty()); + new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel1 = new InputModelType("Model1", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false, []); - var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false, Array.Empty()); + var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false); var inputModel2 = new InputModelType("Model2", "id", "desc", "internal", "description", InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false, []); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index 1ecb0327e59..2dbd786370c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -21,7 +21,7 @@ public void BuildEnumType_ValidateIntBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(int)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], false, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], false); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -42,7 +42,7 @@ public void BuildEnumType_ValidateFloatBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(float)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], false, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], false); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -60,7 +60,7 @@ public void BuildEnumType_ValidateStringBasedFixedEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], false, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], false); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; @@ -77,7 +77,7 @@ public void BuildEnumType_ValidateStringBasedFixedEnum() public void BuildEnumType_ValidateApiVersionEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); - + string[] apiVersions = ["2024-07-16", "2024-07-17"]; var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.String, [new InputEnumTypeValue(apiVersions[0], 1, null), new InputEnumTypeValue(apiVersions[1], 2, null)], false, []); var enumType = EnumProvider.Create(input); @@ -97,7 +97,7 @@ public void BuildEnumType_ValidateIntBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(int)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], true, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, [new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null)], true); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; @@ -135,7 +135,7 @@ public void BuildEnumType_ValidateFloatBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(float)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], true, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, [new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null)], true); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; @@ -173,7 +173,7 @@ public void BuildEnumType_ValidateStringBasedExtensibleEnum() { MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], true, Array.Empty()); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, [new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null)], true); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; var properties = enumType.Properties; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs index 2e40c00b5cd..534ef77effc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs @@ -24,7 +24,7 @@ public void BuildProperties_ValidatePropertySetters(InputModelProperty inputMode inputModelProperty }; - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, props, null, [], null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, props, null, [], null, null, new Dictionary(), null, false); var modelTypeProvider = new ModelProvider(inputModel); var properties = modelTypeProvider.Properties; @@ -46,42 +46,42 @@ public static IEnumerable BuildProperties_ValidatePropertySettersT { // list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IList)), false); // read only list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), false, true, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String), false, true, false), new CSharpType(typeof(IReadOnlyList)), false); // nullable list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IList), true), true); // dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IDictionary)), false); // nullable dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IDictionary), true), true); // primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, false, false), new CSharpType(typeof(string)), true); // read only primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, true, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, true, false), new CSharpType(typeof(string)), false); // readonlymemory property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String), false, false, false), new CSharpType(typeof(ReadOnlyMemory<>)), true); } @@ -105,11 +105,11 @@ public static IEnumerable BuildProperties_ValidatePropertySettersT public void BuildConstructor_ValidateConstructors() { var properties = new List{ - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), - new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()), - new InputModelProperty("optionalUnknown", "optional unknown", "", InputPrimitiveType.Any, false, false, false, Array.Empty()), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), + new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String), true, false, false), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false), + new InputModelProperty("optionalUnknown", "optional unknown", "", InputPrimitiveType.Any, false, false, false), }; MockHelpers.LoadMockPlugin(createCSharpTypeCore: (InputType inputType) => @@ -126,7 +126,7 @@ public void BuildConstructor_ValidateConstructors() } }); - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, false); var modelTypeProvider = new ModelProvider(inputModel); var ctors = modelTypeProvider.Constructors; @@ -144,16 +144,16 @@ public void BuildConstructor_ValidateConstructorsInDerivedModel() { var baseProperties = new List { - new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false), + new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false), }; var derivedProperties = new List { - new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false), + new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false), }; - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false); ((List)inputBase.DerivedModels).Add(inputDerived); MockHelpers.LoadMockPlugin(); @@ -185,8 +185,8 @@ public void BuildConstructor_ValidateConstructorsInDerivedModel() [Test] public void BuildBaseType() { - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, [], null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, [], inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, [], null, new List(), null, null, new Dictionary(), null, false); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, [], inputBase, new List(), null, null, new Dictionary(), null, false); ((List)inputBase.DerivedModels).Add(inputDerived); MockHelpers.LoadMockPlugin(); @@ -202,8 +202,8 @@ public void BuildModelAsStruct() { var properties = new List { - new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false, Array.Empty()), - new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false, Array.Empty()), + new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), + new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), }; MockHelpers.LoadMockPlugin(createCSharpTypeCore: (InputType inputType) => @@ -220,7 +220,7 @@ public void BuildModelAsStruct() } }); - var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, modelAsStruct: true, decorators: Array.Empty()); + var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty(), null, null, new Dictionary(), null, modelAsStruct: true); var modelTypeProvider = new ModelProvider(inputModel); Assert.AreEqual(TypeSignatureModifiers.Public | TypeSignatureModifiers.Struct | TypeSignatureModifiers.Partial | TypeSignatureModifiers.ReadOnly, modelTypeProvider.DeclarationModifiers); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs index eb21a5d18bd..680235bfa66 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyDescriptionTests.cs @@ -66,27 +66,27 @@ public static IEnumerable BuildPropertyDescriptionTestCases { // list property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IList))); // list of binary data property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.Any, Array.Empty()), false, true, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputArrayType("mockProp", "TypeSpec.Array", InputPrimitiveType.Any), false, true, false), new CSharpType(typeof(IReadOnlyList))); // dictionary property with binary data value yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.Any, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.Any), false, false, false), new CSharpType(typeof(IDictionary))); // nullable dictionary property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", new InputDictionaryType("mockProp", InputPrimitiveType.String, InputPrimitiveType.String), false, false, false), new CSharpType(typeof(IDictionary), true)); // primitive type property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, false, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.String, false, false, false), new CSharpType(typeof(string))); // binary data property yield return new TestCaseData( - new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.Any, false, true, false, Array.Empty()), + new InputModelProperty("prop1", "prop1", "public", InputPrimitiveType.Any, false, true, false), new CSharpType(typeof(BinaryData))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs index b6c606ffa63..ace7d621fd7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs @@ -28,8 +28,7 @@ public void TestSnakeCaseProperty() InputPrimitiveType.String, true, false, - false, - Array.Empty()); + false); var property = new PropertyProvider(inputModelProperty); @@ -49,8 +48,7 @@ public void TestPascalCaseProperty() InputPrimitiveType.String, true, false, - false, - Array.Empty()); + false); var property = new PropertyProvider(inputModelProperty); @@ -70,8 +68,7 @@ public void TestCamelCaseProperty() InputPrimitiveType.String, true, false, - false, - Array.Empty()); + false); var property = new PropertyProvider(inputModelProperty); @@ -91,8 +88,7 @@ public void TestKebabCaseProperty() InputPrimitiveType.String, true, false, - false, - Array.Empty()); + false); var property = new PropertyProvider(inputModelProperty); @@ -121,21 +117,19 @@ private static IEnumerable CollectionPropertyTestCases() yield return new TestCaseData( new CSharpType(typeof(IList<>), typeof(string)), new InputModelProperty("readOnlyCollection", "readOnlyCollection", string.Empty, - new InputArrayType("List", "id", InputPrimitiveType.String, Array.Empty()), + new InputArrayType("List", "id", InputPrimitiveType.String), true, true, - false, - Array.Empty()), + false), new CSharpType(typeof(IReadOnlyList<>), typeof(string))); // Dictionary -> IReadOnlyDictionary yield return new TestCaseData( new CSharpType(typeof(IDictionary<,>), typeof(string), typeof(int)), new InputModelProperty("readOnlyDictionary", "readOnlyDictionary", string.Empty, - new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.Int32, Array.Empty()), + new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.Int32), true, true, - false, - Array.Empty()), + false), new CSharpType(typeof(IReadOnlyDictionary<,>), typeof(string), typeof(int))); // string -> string yield return new TestCaseData( @@ -144,7 +138,7 @@ private static IEnumerable CollectionPropertyTestCases() InputPrimitiveType.String, true, true, - false, Array.Empty()), + false), new CSharpType(typeof(string))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs index b89489fc419..f1e4e0d1e6b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs @@ -30,8 +30,7 @@ public void ExtensibleStringEnumType() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true, - Array.Empty()); + true); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, true, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(input); @@ -52,9 +51,8 @@ public void ExtensibleStringNullableEnumType() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true, - Array.Empty()); - var nullableInput = new InputNullableType(input, Array.Empty()); + true); + var nullableInput = new InputNullableType(input); var expected = new CSharpType("SampleType", "Sample.Models", true, true, null, [], true, true, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(nullableInput); @@ -75,8 +73,7 @@ public void ExtensibleStringEnumTypeProvider() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - true, - Array.Empty()); + true); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, true, underlyingEnumType: typeof(string)); var enumProvider = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); @@ -97,8 +94,7 @@ public void FixedStringEnumType() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false, - Array.Empty()); + false); var expected = new CSharpType("SampleType", "Sample.Models", true, false, null, [], true, false, underlyingEnumType: typeof(string)); var actual = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(input); @@ -119,8 +115,7 @@ public void CreateSameEnum() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false, - Array.Empty()); + false); var expected = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); var actual = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs index 87e8a1c8e6f..9e8e8e7ff5a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TypeProviderWriterTests.cs @@ -43,7 +43,7 @@ public void TypeProviderWriter_WriteModel() MockHelpers.LoadMockPlugin(createCSharpTypeCore: MockPluginSetValue(properties)); var inputModel = new InputModelType("TestModel", string.Empty, "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, - properties, null, new List(), null, null, new Dictionary(), null, false, decorators: Array.Empty()); + properties, null, new List(), null, null, new Dictionary(), null, false); var modelProvider = new ModelProvider(inputModel); var codeFile = new TypeProviderWriter(modelProvider).Write(); @@ -61,7 +61,7 @@ public void TypeProviderWriter_WriteModelAsStruct() MockHelpers.LoadMockPlugin(createCSharpTypeCore: MockPluginSetValue(properties)); var inputModel = new InputModelType("TestModel", string.Empty, "public", null, "Test model.", InputModelTypeUsage.Input | InputModelTypeUsage.Output, - properties, null, new List(), null, null, new Dictionary(), null, modelAsStruct: true, decorators: Array.Empty()); + properties, null, new List(), null, null, new Dictionary(), null, modelAsStruct: true); var modelProvider = new ModelProvider(inputModel); var codeFile = new TypeProviderWriter(modelProvider).Write(); @@ -104,12 +104,12 @@ private Func MockPluginSetValue(List } // common usages definitions - internal static readonly InputModelProperty RequiredStringProperty = new InputModelProperty("requiredString", "requiredString", "Required string, illustrating a reference type property.", InputPrimitiveType.String, true, false, false, Array.Empty()); + internal static readonly InputModelProperty RequiredStringProperty = new InputModelProperty("requiredString", "requiredString", "Required string, illustrating a reference type property.", InputPrimitiveType.String, true, false, false); - internal static readonly InputModelProperty RequiredIntProperty = new InputModelProperty("requiredInt", "requiredInt", "Required int, illustrating a value type property.", InputPrimitiveType.Int32, true, false, false, Array.Empty()); + internal static readonly InputModelProperty RequiredIntProperty = new InputModelProperty("requiredInt", "requiredInt", "Required int, illustrating a value type property.", InputPrimitiveType.Int32, true, false, false); - internal static readonly InputModelProperty RequiredStringListProperty = new InputModelProperty("requiredStringList", "requiredStringList", "Required collection of strings, illustrating a collection of reference types.", new InputArrayType("requiredStringList", "TypeSpec.Array", InputPrimitiveType.String, Array.Empty()), true, false, false, Array.Empty()); + internal static readonly InputModelProperty RequiredStringListProperty = new InputModelProperty("requiredStringList", "requiredStringList", "Required collection of strings, illustrating a collection of reference types.", new InputArrayType("requiredStringList", "TypeSpec.Array", InputPrimitiveType.String), true, false, false); - internal static readonly InputModelProperty RequiredIntListProperty = new InputModelProperty("requiredIntList", "requiredIntList", "Required collection of ints, illustrating a collection of value types.", new InputArrayType("requiredIntList", "TypeSpec.Array", InputPrimitiveType.Int32, Array.Empty()), true, false, false, Array.Empty()); + internal static readonly InputModelProperty RequiredIntListProperty = new InputModelProperty("requiredIntList", "requiredIntList", "Required collection of ints, illustrating a collection of value types.", new InputArrayType("requiredIntList", "TypeSpec.Array", InputPrimitiveType.Int32), true, false, false); } } From e6af8154ed2d95daf32a8317d5e4d8c86770360f Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 9 Aug 2024 15:47:08 +0800 Subject: [PATCH 19/26] refine test --- .../MrwSerializationConstructorTests.cs | 4 ++-- .../src/InputTypes/InputEnumTypeValue.cs | 6 +++++- .../TypeSpecInputEnumTypeValueConverter.cs | 13 ++++++++----- .../TypeSpecInputModelTypeConverter.cs | 3 +-- .../TypeSpecInputNullableTypeConverter.cs | 2 +- .../TypeSpecInputUnionTypeConverter.cs | 4 ++-- .../test/Expressions/NewInstanceExpressionTests.cs | 1 - .../test/Providers/EnumProviderTests.cs | 1 - .../test/Providers/PropertyProviderTests.cs | 1 - .../test/TypeFactoryTests.cs | 4 +--- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs index f74c1461a4b..4600ec77f24 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs @@ -44,8 +44,8 @@ public void TestBuildConstructors() new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, []), new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, []), }; - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, Array.Empty()); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, Array.Empty()); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, []); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, []); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs index 20864f29cee..67feb394046 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs @@ -1,20 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; + namespace Microsoft.Generator.CSharp.Input { public class InputEnumTypeValue { - public InputEnumTypeValue(string name, object value, string? description) + public InputEnumTypeValue(string name, object value, string? description, IReadOnlyList? decorators = null) { Name = name; Value = value; Description = description; + Decorators = decorators ?? []; } public string Name { get; } public object Value { get; } public string? Description { get; } + public IReadOnlyList Decorators { get; internal set; } public virtual string GetJsonValueString() => GetValueString(); public string GetValueString() => Value.ToString() ?? string.Empty; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs index 1b256375405..b277a60da98 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs @@ -1,7 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -17,22 +18,24 @@ public TypeSpecInputEnumTypeValueConverter(TypeSpecReferenceHandler referenceHan } public override InputEnumTypeValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - => reader.ReadReferenceAndResolve(_referenceHandler.CurrentResolver) ?? CreateEnumTypeValue(ref reader, null, null, _referenceHandler.CurrentResolver); + => reader.ReadReferenceAndResolve(_referenceHandler.CurrentResolver) ?? CreateEnumTypeValue(ref reader, null, null, options, _referenceHandler.CurrentResolver); public override void Write(Utf8JsonWriter writer, InputEnumTypeValue value, JsonSerializerOptions options) => throw new NotSupportedException("Writing not supported"); - public static InputEnumTypeValue CreateEnumTypeValue(ref Utf8JsonReader reader, string? id, string? name, ReferenceResolver resolver) + public static InputEnumTypeValue CreateEnumTypeValue(ref Utf8JsonReader reader, string? id, string? name, JsonSerializerOptions options, ReferenceResolver resolver) { var isFirstProperty = id == null; object? value = null; string? description = null; + IReadOnlyList? decorators = null; while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputEnumTypeValue.Name), ref name) || reader.TryReadEnumValue(nameof(InputEnumTypeValue.Value), ref value) - || reader.TryReadString(nameof(InputEnumTypeValue.Description), ref description); + || reader.TryReadString(nameof(InputEnumTypeValue.Description), ref description) + || reader.TryReadWithConverter(nameof(InputEnumTypeValue.Decorators), options, ref decorators); if (!isKnownProperty) { @@ -44,7 +47,7 @@ public static InputEnumTypeValue CreateEnumTypeValue(ref Utf8JsonReader reader, value = value ?? throw new JsonException("EnumValue must have value"); - var enumValue = new InputEnumTypeValue(name, value, description); + var enumValue = new InputEnumTypeValue(name, value, description, decorators); if (id != null) { resolver.AddReference(id, enumValue); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs index 54ec774e321..537b0a9e666 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelTypeConverter.cs @@ -47,8 +47,7 @@ public static InputModelType CreateModelType(ref Utf8JsonReader reader, string? discriminatorProperty: null, discriminatedSubtypes: null!, additionalProperties: null, - modelAsStruct: false, - decorators: Array.Empty()); + modelAsStruct: false); resolver.AddReference(id, model); string? crossLanguageDefinitionId = null; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 4d5690517c6..2b6d1e232b0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -32,7 +32,7 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) || reader.TryReadString(nameof(InputNullableType.Name), ref name) || reader.TryReadWithConverter(nameof(InputNullableType.Type), options, ref valueType) - || reader.TryReadWithConverter(nameof(InputNullableType.Type), options, ref decorators); + || reader.TryReadWithConverter(nameof(InputNullableType.Decorators), options, ref decorators); if (!isKnownProperty) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs index 1c2e6e046a3..2738b739ac9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputUnionTypeConverter.cs @@ -32,7 +32,7 @@ public static InputUnionType CreateInputUnionType(ref Utf8JsonReader reader, str id = id ?? throw new JsonException(); // create an empty model to resolve circular references - var union = new InputUnionType(null!, null!, Array.Empty()); + var union = new InputUnionType(null!, null!); resolver.AddReference(id, union); IReadOnlyList? variantTypes = null; @@ -55,7 +55,7 @@ public static InputUnionType CreateInputUnionType(ref Utf8JsonReader reader, str throw new JsonException("Union must have a least one union type"); } union.VariantTypes = variantTypes; - union.Decorators = decorators ?? Array.Empty(); + union.Decorators = decorators ?? []; return union; } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs index d772007f2fd..892286ec4d5 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Expressions/NewInstanceExpressionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index 2dbd786370c..d1500bacb7e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs index ace7d621fd7..a776bcc442f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/PropertyProviderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs index f1e4e0d1e6b..c61e7d58b37 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/TypeFactoryTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; @@ -135,8 +134,7 @@ public void CreateEnum_WithDeclaringType() InputModelTypeUsage.Input, InputPrimitiveType.String, [new InputEnumTypeValue("value1", "value1", null), new InputEnumTypeValue("value2", "value2", null)], - false, - []); + false); var declaringType = new Mock().Object; var expected = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input, declaringType); var actual = CodeModelPlugin.Instance.TypeFactory.CreateEnum(input, declaringType); From 403867fa8670f0076defc4ab6b558368d0e5cd9c Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Mon, 12 Aug 2024 13:38:00 +0800 Subject: [PATCH 20/26] remove decorators parameter in input model client constructor --- .../test/InputLibraryVisitorTests.cs | 14 +++---- .../Providers/ClientOptionsProviderTests.cs | 13 +++--- .../ClientProviderSubClientTests.cs | 10 ++--- .../ClientProviders/ClientProviderTests.cs | 40 +++++++++---------- .../EnumProviderSerializationTests.cs | 6 +-- .../JsonModelCoreTests.cs | 21 ++++------ .../MrwSerializationConstructorTests.cs | 12 +++--- .../MrwSerializationTypeDefinitionTests.cs | 40 +++++++++---------- .../PersistableModelCoreTests.cs | 4 +- .../test/Providers/RestClientProviderTests.cs | 7 ++-- .../ScmMethodProviderCollectionTests.cs | 8 ++-- .../TestHelpers/TestClientTypeProvider.cs | 2 +- .../test/InputLibraryVisitorTests.cs | 12 +++--- .../test/Providers/EnumProviderTests.cs | 2 +- .../Providers/ModelFactoryProviderTests.cs | 21 +++++----- .../test/Providers/ModelProviderTests.cs | 2 +- 16 files changed, 100 insertions(+), 114 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs index 5725f49a30e..0e57bdffd55 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs @@ -33,22 +33,22 @@ public void PreVisitsMethods() { _mockPlugin.Object.AddVisitor(_mockVisitor.Object); var inputModelProperty = - new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false, []); + new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel = new InputModelType("foo", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false); var param = new InputParameter("param", "name", "desc", - new InputLiteralType(new InputPrimitiveType(InputPrimitiveTypeKind.String, "foo", "bar"), "bar", []), + new InputLiteralType(new InputPrimitiveType(InputPrimitiveTypeKind.String, "foo", "bar"), "bar"), RequestLocation.Header, null, InputOperationParameterKind.Method, true, false, true, false, false, false, false, null, null, []); - var inputOperation = new InputOperation("testoperation", "name", "desc", null, null, [param], new[] { new OperationResponse([200], new InputLiteralType(InputPrimitiveType.Any, "foo", []), BodyMediaType.Json, [], false, []) }, - "GET", BodyMediaType.Json, "http://example.com", "baz", null, null, true, null, null, true, true, "foo", []); + var inputOperation = new InputOperation("testoperation", "name", "desc", null, null, [param], new[] { new OperationResponse([200], new InputLiteralType(InputPrimitiveType.Any, "foo"), BodyMediaType.Json, [], false, []) }, + "GET", BodyMediaType.Json, "http://example.com", "baz", null, null, true, null, null, true, true, "foo"); var inputClient = new InputClient( "fooClient", "desc", [inputOperation], [param], - null, []); + null); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", new List(), @@ -64,7 +64,7 @@ public void PreVisitsMethods() inputOperation }, [param], - null, []) + null) }, new InputAuth())); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs index 46192292b61..1d72538fea4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientOptionsProviderTests.cs @@ -40,8 +40,7 @@ public void SetUp() InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.Int64, enumValues, - false, - []); + false); MockHelpers.LoadMockPlugin( apiVersions: () => apiVersions, @@ -56,7 +55,7 @@ public void SetUp() [Test] public void TestImplements() { - var client = new InputClient("TestClient", "TestClient description", [], [], null, []); + var client = new InputClient("TestClient", "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -72,7 +71,7 @@ public void TestImplements() [TestCase(false)] public void TestFields(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null, []); + var client = new InputClient("TestClient", "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -95,7 +94,7 @@ public void TestFields(bool containsApiVersions) [TestCase(false)] public void TestNestedTypes(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null, []); + var client = new InputClient("TestClient", "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -123,7 +122,7 @@ public void TestNestedTypes(bool containsApiVersions) [TestCase(false)] public void TestConstructors(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null, []); + var client = new InputClient("TestClient", "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); @@ -152,7 +151,7 @@ public void TestConstructors(bool containsApiVersions) [TestCase(false)] public void TestProperties(bool containsApiVersions) { - var client = new InputClient("TestClient", "TestClient description", [], [], null, []); + var client = new InputClient("TestClient", "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); var clientOptionsProvider = new ClientOptionsProvider(client, clientProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderSubClientTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderSubClientTests.cs index 793bb49bd44..e58c00b36a6 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderSubClientTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderSubClientTests.cs @@ -13,10 +13,10 @@ namespace Microsoft.Generator.CSharp.ClientModel.Tests.Providers.ClientProviders public class ClientProviderSubClientTests { private const string TestClientName = "TestClient"; - private static readonly InputClient _animalClient = new("animal", "AnimalClient description", [], [], TestClientName, []); - private static readonly InputClient _dogClient = new("dog", "DogClient description", [], [], _animalClient.Name, []); - private static readonly InputClient _catClient = new("cat", "CatClient description", [], [], _animalClient.Name, []); - private static readonly InputClient _huskyClient = new("husky", "HuskyClient description", [], [], _dogClient.Name, []); + private static readonly InputClient _animalClient = new("animal", "AnimalClient description", [], [], TestClientName); + private static readonly InputClient _dogClient = new("dog", "DogClient description", [], [], _animalClient.Name); + private static readonly InputClient _catClient = new("cat", "CatClient description", [], [], _animalClient.Name); + private static readonly InputClient _huskyClient = new("husky", "HuskyClient description", [], [], _dogClient.Name); [SetUp] public void SetUp() @@ -30,7 +30,7 @@ public void SetUp() [Test] public void ServiceClientWithSubClient() { - var client = new InputClient(TestClientName, "TestClient description", [], [], null, []); + var client = new InputClient(TestClientName, "TestClient description", [], [], null); string[] expectedSubClientFactoryMethodNames = [$"Get{_animalClient.Name.ToCleanName()}Client"]; var clientProvider = new MockClientProvider(client, expectedSubClientFactoryMethodNames); var writer = new TypeProviderWriter(clientProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs index c240e48ad63..df18c74c5eb 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs @@ -21,9 +21,9 @@ public class ClientProviderTests { private const string SubClientsCategory = "WithSubClients"; private const string TestClientName = "TestClient"; - private static readonly InputClient _animalClient = new("animal", "AnimalClient description", [], [], TestClientName, []); - private static readonly InputClient _dogClient = new("dog", "DogClient description", [], [], _animalClient.Name, []); - private static readonly InputClient _huskyClient = new("husky", "HuskyClient description", [], [], _dogClient.Name, []); + private static readonly InputClient _animalClient = new("animal", "AnimalClient description", [], [], TestClientName); + private static readonly InputClient _dogClient = new("dog", "DogClient description", [], [], _animalClient.Name); + private static readonly InputClient _huskyClient = new("husky", "HuskyClient description", [], [], _dogClient.Name); [SetUp] public void SetUp() @@ -46,7 +46,7 @@ public void SetUp() [Test] public void TestBuildProperties() { - var client = new InputClient(TestClientName, "TestClient description", [], [], null, []); + var client = new InputClient(TestClientName, "TestClient description", [], [], null); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -66,7 +66,7 @@ public void TestBuildProperties() [TestCaseSource(nameof(BuildFieldsTestCases))] public void TestBuildFields(List inputParameters, bool containsAdditionalOptionalParams) { - var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null, []); + var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -140,7 +140,7 @@ public void TestBuildFields_WithSubClients(InputClient client, bool hasSubClient [TestCaseSource(nameof(BuildConstructorsTestCases))] public void TestBuildConstructors_PrimaryConstructor(List inputParameters) { - var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null, []); + var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -156,7 +156,7 @@ public void TestBuildConstructors_PrimaryConstructor(List inputP [TestCaseSource(nameof(BuildConstructorsTestCases))] public void TestBuildConstructors_SecondaryConstructor(List inputParameters) { - var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null, []); + var client = new InputClient(TestClientName, "TestClient description", [], inputParameters, null); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -259,7 +259,7 @@ private void ValidateSecondaryConstructor( [TestCaseSource(nameof(EndpointParamInitializationValueTestCases))] public void EndpointInitializationValue(InputParameter endpointParameter, ValueExpression? expectedValue) { - var client = new InputClient(TestClientName, "TestClient description", [], [endpointParameter], null, []); + var client = new InputClient(TestClientName, "TestClient description", [], [endpointParameter], null); var clientProvider = new ClientProvider(client); Assert.IsNotNull(clientProvider); @@ -286,7 +286,7 @@ public void TestGetClientOptions(bool isSubClient) parentClientName = "parent"; } - var client = new InputClient(TestClientName, "TestClient description", [], [], parentClientName, []); + var client = new InputClient(TestClientName, "TestClient description", [], [], parentClientName); var clientProvider = new ClientProvider(client); if (isSubClient) @@ -348,7 +348,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []), + isRequired: false, false, false, false, false, false, false, null, null), new( KnownParameters.Endpoint.Name, "endpoint description", @@ -357,7 +357,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null) }, false); yield return new TestCaseData(new List { @@ -369,7 +369,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: new InputConstant("someValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []), + isRequired: false, false, false, false, false, false, false, null, null), new( "optionalParam2", "optionalParam description", @@ -378,7 +378,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: new InputConstant("someValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []), + isRequired: false, false, false, false, false, false, false, null, null), new( "optionalParam3", "optionalParam description", @@ -387,7 +387,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: new InputConstant(2, InputPrimitiveType.Int64), InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []), + isRequired: false, false, false, false, false, false, false, null, null), new( KnownParameters.Endpoint.Name, "endpoint description", @@ -396,7 +396,7 @@ public static IEnumerable BuildFieldsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null) }, true); } } @@ -426,7 +426,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []), + isRequired: false, false, false, false, false, false, false, null, null), new( KnownParameters.Endpoint.Name, "endpoint description", @@ -435,7 +435,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: new InputConstant("someValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, isEndpoint: true, false, false, null, null, []) + isRequired: false, false, false, false, isEndpoint: true, false, false, null, null) }); // scenario where endpoint is required yield return new TestCaseData(new List @@ -448,7 +448,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: true, false, false, false, isEndpoint: true, false, false, null, null, []), + isRequired: true, false, false, false, isEndpoint: true, false, false, null, null), new( "optionalParam", "optionalParam description", @@ -457,7 +457,7 @@ public static IEnumerable BuildConstructorsTestCases RequestLocation.None, defaultValue: null, InputOperationParameterKind.Client, - isRequired: false, false, false, false, false, false, false, null, null, []) + isRequired: false, false, false, false, false, false, false, null, null) }); } } @@ -474,7 +474,7 @@ private static IEnumerable EndpointParamInitializationValueTestCas RequestLocation.None, defaultValue: new InputConstant("mockValue", InputPrimitiveType.String), InputOperationParameterKind.Client, - isRequired: false, false, false, false, true, false, false, null, null, []), + isRequired: false, false, false, false, true, false, false, null, null), New.Instance(KnownParameters.Endpoint.Type, Literal("mockvalue"))); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs index eb378c696c4..9f889a98e56 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/EnumProviderSerializationTests.cs @@ -27,21 +27,21 @@ private static object[] ValidateTypes(bool isExtensible) new InputEnumTypeValue("One", 1, null), new InputEnumTypeValue("Two", 2, null) }; - var intType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, intValues, isExtensible, []); + var intType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Int32, intValues, isExtensible); var floatValues = new List { new InputEnumTypeValue("One", 1f, null), new InputEnumTypeValue("Two", 2f, null) }; - var floatType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, floatValues, isExtensible, []); + var floatType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.Float32, floatValues, isExtensible); var stringValues = new List { new InputEnumTypeValue("One", "1", null), new InputEnumTypeValue("Two", "2", null) }; - var stringType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, stringValues, isExtensible, []); + var stringType = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.Input | InputModelTypeUsage.Output, InputPrimitiveType.String, stringValues, isExtensible); return [intType, floatType, stringType]; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index 0ef88a1d91a..84d648e50d7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -46,8 +46,7 @@ public void KebabCaseSerializedName() InputPrimitiveType.String, true, false, - false, - []); + false); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -62,8 +61,7 @@ public void KebabCaseSerializedName() null, new Dictionary(), null, - false, - []); + false); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -96,8 +94,7 @@ public void SnakeCaseSerializedName() null, new Dictionary(), null, - false, - Array.Empty()); + false); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -115,8 +112,7 @@ public void PascalCaseSerializedName() InputPrimitiveType.String, true, false, - false, - []); + false); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -131,8 +127,7 @@ public void PascalCaseSerializedName() null, new Dictionary(), null, - false, - []); + false); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); @@ -150,8 +145,7 @@ public void CamelCaseSerializedName() InputPrimitiveType.String, true, false, - false, - []); + false); var inputModel = new InputModelType( "TestModel", "TestModel", @@ -166,8 +160,7 @@ public void CamelCaseSerializedName() null, new Dictionary(), null, - false, - []); + false); var mrwProvider = new ModelProvider(inputModel).SerializationProviders.First(); var writer = new TypeProviderWriter(mrwProvider); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs index 4600ec77f24..0fefcd0ed6f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationConstructorTests.cs @@ -36,16 +36,16 @@ public void TestBuildConstructors() { var baseProperties = new List { - new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false, []), - new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false, []), + new InputModelProperty("prop1", "prop1", string.Empty, InputPrimitiveType.String, true, false, false), + new InputModelProperty("prop2", "prop2", string.Empty, InputPrimitiveType.String, false, false, false), }; var derivedProperties = new List { - new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false, []), - new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false, []), + new InputModelProperty("prop3", "prop3", string.Empty, InputPrimitiveType.String, true, false, false), + new InputModelProperty("prop4", "prop4", string.Empty, InputPrimitiveType.String, false, false, false), }; - var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false, []); - var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false, []); + var inputBase = new InputModelType("baseModel", "baseModel", null, null, null, InputModelTypeUsage.Input, baseProperties, null, new List(), null, null, new Dictionary(), null, false); + var inputDerived = new InputModelType("derivedModel", "derivedModel", null, null, null, InputModelTypeUsage.Input, derivedProperties, inputBase, new List(), null, null, new Dictionary(), null, false); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index 495b5b60237..759151f6167 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -40,7 +40,7 @@ internal static (TypeProvider Model, MrwSerializationTypeDefinition Serializatio public void TestBuildImplements() { // mock the model type provider - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var interfaces = serialization.Implements; @@ -57,7 +57,7 @@ public void TestBuildImplements() [Test] public void TestBuildJsonModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteCoreMethod(); @@ -92,7 +92,7 @@ public void TestBuildJsonModelWriteCoreMethod() [Test] public void TestBuildJsonModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteMethodObjectDeclaration(); @@ -126,7 +126,7 @@ public void TestBuildJsonModelWriteMethodObjectDeclaration() [Test] public void TestBuildJsonModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethod(); @@ -146,7 +146,7 @@ public void TestBuildJsonModelCreateMethod() [Test] public void TestBuildJsonModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateCoreMethod(); @@ -181,7 +181,7 @@ public void TestBuildJsonModelCreateCoreMethod() [Test] public void TestBuildJsonModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateMethodObjectDeclaration(); @@ -216,7 +216,7 @@ public void TestBuildJsonModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelWriteMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethod(); @@ -236,7 +236,7 @@ public void TestBuildPersistableModelWriteMethod() [Test] public void TestBuildPersistableModelWriteCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteCoreMethod(); @@ -271,7 +271,7 @@ public void TestBuildPersistableModelWriteCoreMethod() [Test] public void TestBuildPersistableModelWriteMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteMethodObjectDeclaration(); @@ -305,7 +305,7 @@ public void TestBuildPersistableModelWriteMethodObjectDeclaration() [Test] public void TestBuildPersistableModelCreateMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -335,7 +335,7 @@ public void TestBuildPersistableModelCreateMethod() [Test] public void TestBuildPersistableModelCreateCoreMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); Assert.IsNotNull(serialization); @@ -364,7 +364,7 @@ public void TestBuildPersistableModelCreateCoreMethod() [Test] public void BuildPersistableModelCreateMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethodObjectDeclaration(); @@ -398,7 +398,7 @@ public void BuildPersistableModelCreateMethodObjectDeclaration() [Test] public void TestBuildPersistableModelDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelCreateMethod(); @@ -418,7 +418,7 @@ public void TestBuildPersistableModelDeserializationMethod() [Test] public void TestBuildPersistableModelGetFormatMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsMethod(); @@ -441,7 +441,7 @@ public void TestBuildPersistableModelGetFormatMethod() [Test] public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, true); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelGetFormatFromOptionsObjectDeclaration(); @@ -474,7 +474,7 @@ public void TestBuildPersistableModelGetFormatMethodObjectDeclaration() [Test] public void TestBuildSerializationConstructor() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var constructor = serialization.BuildSerializationConstructor(); @@ -491,7 +491,7 @@ public void TestBuildSerializationConstructor() [Test] public void TestBuildFields() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var fields = serialization.Fields; @@ -535,7 +535,7 @@ public void TestBuildConstructor_ValidateConstructors() [Test] public void TestBuildDeserializationMethod() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var deserializationMethod = serialization.BuildDeserializationMethod(); @@ -557,7 +557,7 @@ public void TestBuildDeserializationMethod() [Test] public void TestBuildImplicitToBinaryContent() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; @@ -585,7 +585,7 @@ public void TestBuildImplicitToBinaryContent() [Test] public void TestBuildExplicitFromClientResult() { - var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false, []); + var inputModel = new InputModelType("mockInputModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, Array.Empty(), null, new List(), null, null, new Dictionary(), null, false); var (model, serialization) = CreateModelAndSerialization(inputModel); var methods = serialization.Methods; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs index 73240804c07..9f5464b422a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/PersistableModelCoreTests.cs @@ -38,9 +38,9 @@ protected override MethodProvider[] BuildMethods() [Test] public void TestBuildPersistableModelCreateCoreMethod_DerivedType() { - var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, [], null, new List(), null, null, new Dictionary(), null, false, []); + var inputBase = new InputModelType("mockBaseModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, [], null, new List(), null, null, new Dictionary(), null, false); var inputDerived = new InputModelType("mockDerivedModel", "mockNamespace", "public", null, null, InputModelTypeUsage.Input | InputModelTypeUsage.Output, - [], inputBase, new List(), null, null, new Dictionary(), null, false, []); + [], inputBase, new List(), null, null, new Dictionary(), null, false); ((List)inputBase.DerivedModels).Add(inputDerived); var (baseModel, baseSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputBase); var (derivedModel, derivedSerialization) = MrwSerializationTypeDefinitionTests.CreateModelAndSerialization(inputDerived); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs index 3ff8ff3f8bb..58690865aa6 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/RestClientProviderTests.cs @@ -104,7 +104,7 @@ public void ValidateProperties() accessibility: null, parameters: [ - new InputParameter("message", "message", "The message to create.", InputPrimitiveType.Boolean, RequestLocation.Body, null, InputOperationParameterKind.Method, true, false, false, false, false, false, false, null, null, []) + new InputParameter("message", "message", "The message to create.", InputPrimitiveType.Boolean, RequestLocation.Body, null, InputOperationParameterKind.Method, true, false, false, false, false, false, false, null, null) ], responses: [new OperationResponse([200], null, BodyMediaType.Json, [], false, ["application/json"])], httpMethod: "GET", @@ -118,10 +118,9 @@ public void ValidateProperties() paging: null, generateProtocolMethod: true, generateConvenienceMethod: true, - crossLanguageDefinitionId: "TestService.CreateMessage", - decorators: []); + crossLanguageDefinitionId: "TestService.CreateMessage"); - private readonly static InputClient SingleOpInputClient = new InputClient("TestClient", "TestClient description", [BasicOperation], [], null, []); + private readonly static InputClient SingleOpInputClient = new InputClient("TestClient", "TestClient description", [BasicOperation], [], null); private static IEnumerable DefaultCSharpMethodCollectionTestCases => [ diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs index 6f3e1ac58a9..7eae282340d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs @@ -17,7 +17,7 @@ internal class ScmMethodProviderCollectionTests [TestCaseSource(nameof(DefaultCSharpMethodCollectionTestCases))] public void TestDefaultCSharpMethodCollection(InputOperation inputOperation) { - var inputClient = new InputClient("TestClient", "TestClient description", [inputOperation], [], null, []); + var inputClient = new InputClient("TestClient", "TestClient description", [inputOperation], [], null); MockHelpers.LoadMockPlugin( createCSharpTypeCore: (inputType) => new CSharpType(typeof(bool)), @@ -65,8 +65,7 @@ public static IEnumerable DefaultCSharpMethodCollectionTestCases false, false, null, - null, - []) + null) ], responses: [new OperationResponse([200], null, BodyMediaType.Json, [], false, ["application/json"])], httpMethod: "GET", @@ -80,8 +79,7 @@ public static IEnumerable DefaultCSharpMethodCollectionTestCases paging: null, generateProtocolMethod: true, generateConvenienceMethod: true, - crossLanguageDefinitionId: "TestService.CreateMessage", - decorators: [] + crossLanguageDefinitionId: "TestService.CreateMessage" )); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs index e38e1aafafe..3d7fd266887 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/TestHelpers/TestClientTypeProvider.cs @@ -10,7 +10,7 @@ internal class TestClientTypeProvider : ClientProvider { public static readonly ClientProvider Empty = new TestClientTypeProvider(); - public TestClientTypeProvider() : base(new InputClient("TestClient", "TestClient description", [], [], null, [])) + public TestClientTypeProvider() : base(new InputClient("TestClient", "TestClient description", [], [], null)) { } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs index 598f26f0058..994fab02dff 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs @@ -35,7 +35,7 @@ public void PreVisitsProperties() var inputModelProperty = new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel = new InputModelType("foo", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", @@ -62,7 +62,7 @@ public void PreVisitsEnum() var inputModelProperty = new InputModelProperty("prop1", "prop1", "string", inputEnum, true, true, false); var inputModel = new InputModelType("foo", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModelProperty], null, [], null, null, new Dictionary(), null, false); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", @@ -85,12 +85,12 @@ public void RemovedInputModelCausesExceptionWhenReferencedInDifferentModel() var inputModel1Property = new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel1 = new InputModelType("Model1", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false); var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false); var inputModel2 = new InputModelType("Model2", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", @@ -111,12 +111,12 @@ public void CanCleanUpRemovedReferencesToRemovedModels() var inputModel1Property = new InputModelProperty("prop1", "prop1", "string", new InputPrimitiveType(InputPrimitiveTypeKind.Any, "foo", "bar"), true, true, false); var inputModel1 = new InputModelType("Model1", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModel1Property], null, [], null, null, new Dictionary(), null, false); var inputModel2Property = new InputModelProperty("prop2", "prop1", "string", inputModel1, true, true, false); var inputModel2 = new InputModelType("Model2", "id", "desc", "internal", "description", - InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false, []); + InputModelTypeUsage.Input, [inputModel2Property], null, [], null, null, new Dictionary(), null, false); _mockInputLibrary.Setup(l => l.InputNamespace).Returns(new InputNamespace( "test library", diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index d1500bacb7e..42014310eef 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -78,7 +78,7 @@ public void BuildEnumType_ValidateApiVersionEnum() MockHelpers.LoadMockPlugin(createCSharpTypeCore: (inputType) => typeof(string)); string[] apiVersions = ["2024-07-16", "2024-07-17"]; - var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.String, [new InputEnumTypeValue(apiVersions[0], 1, null), new InputEnumTypeValue(apiVersions[1], 2, null)], false, []); + var input = new InputEnumType("mockInputEnum", "mockNamespace", "public", null, "The mock enum", InputModelTypeUsage.ApiVersionEnum, InputPrimitiveType.String, [new InputEnumTypeValue(apiVersions[0], 1, null), new InputEnumTypeValue(apiVersions[1], 2, null)], false); var enumType = EnumProvider.Create(input); var fields = enumType.Fields; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs index cb074aaeecc..bb4e80b6e35 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs @@ -94,8 +94,8 @@ private static InputModelType[] GetTestModels() InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType, []), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType, []), false, false, false, [], null) + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) ], null, [], @@ -103,8 +103,7 @@ private static InputModelType[] GetTestModels() null, new Dictionary(), null, - false, - []), + false), new InputModelType( "PublicModel1", "PublicModel1", @@ -114,8 +113,8 @@ private static InputModelType[] GetTestModels() InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType, []), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType, []), false, false, false, [], null) + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) ], null, [], @@ -123,8 +122,7 @@ private static InputModelType[] GetTestModels() null, new Dictionary(), null, - false, - []), + false), new InputModelType( "PublicModel2", "PublicModel2", @@ -134,8 +132,8 @@ private static InputModelType[] GetTestModels() InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType, []), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType, []), false, false, false, [], null) + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) ], null, [], @@ -143,8 +141,7 @@ private static InputModelType[] GetTestModels() null, new Dictionary(), null, - false, - []) + false) ]; } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs index 534ef77effc..9be72c0d4b5 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviderTests.cs @@ -108,7 +108,7 @@ public void BuildConstructor_ValidateConstructors() new InputModelProperty("requiredString", "requiredString", "", InputPrimitiveType.String, true, false, false), new InputModelProperty("OptionalInt", "optionalInt", "", InputPrimitiveType.Int32, false, false, false), new InputModelProperty("requiredCollection", "requiredCollection", "", new InputArrayType("List", "TypeSpec.Array", InputPrimitiveType.String), true, false, false), - new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String, Array.Empty()), true, false, false), + new InputModelProperty("requiredDictionary", "requiredDictionary", "", new InputDictionaryType("Dictionary", InputPrimitiveType.String, InputPrimitiveType.String), true, false, false), new InputModelProperty("optionalUnknown", "optional unknown", "", InputPrimitiveType.Any, false, false, false), }; From 9280ae971ffcdda8c0be7b33433ca1abc5beb993 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Mon, 12 Aug 2024 13:41:05 +0800 Subject: [PATCH 21/26] refine test --- .../test/InputLibraryVisitorTests.cs | 2 +- .../ClientProviders/ClientProviderTests.cs | 2 +- .../JsonModelCoreTests.cs | 1 - .../test/Providers/EnumProviderTests.cs | 2 ++ .../Providers/ModelFactoryProviderTests.cs | 18 +++++++++--------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs index 0e57bdffd55..d446d20b4da 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/InputLibraryVisitorTests.cs @@ -40,7 +40,7 @@ public void PreVisitsMethods() var param = new InputParameter("param", "name", "desc", new InputLiteralType(new InputPrimitiveType(InputPrimitiveTypeKind.String, "foo", "bar"), "bar"), RequestLocation.Header, null, InputOperationParameterKind.Method, true, false, true, false, false, - false, false, null, null, []); + false, false, null, null); var inputOperation = new InputOperation("testoperation", "name", "desc", null, null, [param], new[] { new OperationResponse([200], new InputLiteralType(InputPrimitiveType.Any, "foo"), BodyMediaType.Json, [], false, []) }, "GET", BodyMediaType.Json, "http://example.com", "baz", null, null, true, null, null, true, true, "foo"); var inputClient = new InputClient( diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs index df18c74c5eb..26b414e7324 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ClientProviders/ClientProviderTests.cs @@ -405,7 +405,7 @@ public static IEnumerable SubClientTestCases { get { - yield return new TestCaseData(new InputClient(TestClientName, "TestClient description", [], [], null, []), true); + yield return new TestCaseData(new InputClient(TestClientName, "TestClient description", [], [], null), true); yield return new TestCaseData(_animalClient, true); yield return new TestCaseData(_dogClient, true); yield return new TestCaseData(_huskyClient, false); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs index 84d648e50d7..059503adf90 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/JsonModelCoreTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using System.Linq; using Microsoft.Generator.CSharp.ClientModel.Providers; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs index 42014310eef..4fba0386926 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/EnumProviderTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Linq; +using System.Text; using Microsoft.Generator.CSharp.Expressions; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs index bb4e80b6e35..cde85bb99b9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactoryProviderTests.cs @@ -93,9 +93,9 @@ private static InputModelType[] GetTestModels() "InternalModel", InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ - new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) + new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, null), + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, null) ], null, [], @@ -112,9 +112,9 @@ private static InputModelType[] GetTestModels() "PublicModel1", InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ - new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) + new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, null), + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, null) ], null, [], @@ -131,9 +131,9 @@ private static InputModelType[] GetTestModels() "PublicModel2", InputModelTypeUsage.Input | InputModelTypeUsage.Output, [ - new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, [], null), - new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, [], null), - new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, [], null) + new InputModelProperty("StringProp", "stringProp", "StringProp", StringInputType, false, false, false, null), + new InputModelProperty("ListProp", "listProp", "ListProp", new InputArrayType("list", "list", StringInputType), false, false, false, null), + new InputModelProperty("DictProp", "DictProp", "DictProp", new InputDictionaryType("dict", StringInputType, StringInputType), false, false, false, null) ], null, [], From 5b30017dd4e58a5eae02642528c6f5cce6591bbb Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 14 Aug 2024 10:09:00 +0800 Subject: [PATCH 22/26] remove decorators parameter from constructor --- .../src/InputTypes/InputArrayType.cs | 4 +--- .../src/InputTypes/InputClient.cs | 7 +++---- .../src/InputTypes/InputDateTimeType.cs | 2 +- .../src/InputTypes/InputDictionaryType.cs | 4 +--- .../src/InputTypes/InputDurationType.cs | 4 +--- .../src/InputTypes/InputEnumType.cs | 4 ++-- .../src/InputTypes/InputEnumTypeValue.cs | 5 ++--- .../src/InputTypes/InputLiteralType.cs | 4 +--- .../src/InputTypes/InputModelProperty.cs | 6 ++---- .../src/InputTypes/InputModelType.cs | 4 ++-- .../src/InputTypes/InputNullableType.cs | 5 +---- .../src/InputTypes/InputOperation.cs | 9 +++------ .../src/InputTypes/InputParameter.cs | 6 ++---- .../src/InputTypes/InputPrimitiveType.cs | 9 +++------ .../src/InputTypes/InputType.cs | 17 ++++++++++------- .../src/InputTypes/InputUnionType.cs | 2 +- .../TypeSpecInputArrayTypeConverter.cs | 3 ++- .../TypeSpecInputDateTimeTypeConverter.cs | 2 +- .../TypeSpecInputDictionaryTypeConverter.cs | 5 ++++- .../TypeSpecInputDurationTypeConverter.cs | 2 +- .../TypeSpecInputEnumTypeConverter.cs | 5 ++++- .../TypeSpecInputEnumTypeValueConverter.cs | 2 +- .../TypeSpecInputLiteralTypeConverter.cs | 5 ++++- .../TypeSpecInputModelPropertyConverter.cs | 2 +- .../TypeSpecInputNullableTypeConverter.cs | 5 ++++- .../TypeSpecInputParameterConverter.cs | 6 ++++-- .../TypeSpecInputPrimitiveTypeConverter.cs | 5 ++++- 27 files changed, 66 insertions(+), 68 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs index 629c933046c..1491d0cf475 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputArrayType.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { /// @@ -14,7 +12,7 @@ public sealed class InputArrayType : InputType /// The name of the list type. /// The crossLanguageDefinitionId of the list type. For a builtin array, it should be `TypeSpec.Array`. /// The element's . - public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType, IReadOnlyList? decorators = null) : base(name, decorators) + public InputArrayType(string name, string crossLanguageDefinitionId, InputType valueType) : base(name) { CrossLanguageDefinitionId = crossLanguageDefinitionId; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs index 895c38e6eb1..38d90dbf1c3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputClient.cs @@ -11,24 +11,23 @@ public class InputClient private readonly string? _key; private IReadOnlyDictionary? _examples; - public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent, IReadOnlyList? decorators = null) + public InputClient(string name, string description, IReadOnlyList operations, IReadOnlyList parameters, string? parent) { Name = name; Description = description; Operations = operations; Parameters = parameters; Parent = parent; - Decorators = decorators ?? []; } - public InputClient() : this(string.Empty, string.Empty, Array.Empty(), Array.Empty(), null, Array.Empty()) { } + public InputClient() : this(string.Empty, string.Empty, Array.Empty(), Array.Empty(), null) { } public string Name { get; internal set; } public string Description { get; internal set; } public IReadOnlyList Operations { get; internal set; } public IReadOnlyList Parameters { get; internal set; } public string? Parent { get; internal set; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); public string Key { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs index 08676ad5f32..5a532379844 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputDateTimeType : InputType { - public InputDateTimeType(DateTimeKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDateTimeType? baseType = null, IReadOnlyList? decorators = null) : base(name, decorators) + public InputDateTimeType(DateTimeKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDateTimeType? baseType = null) : base(name) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Encode = encode; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs index cb70db74402..c2b88a1fcd7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDictionaryType.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { /// @@ -15,7 +13,7 @@ public sealed class InputDictionaryType : InputType /// The key's . /// The value's . /// Flag used to determine if the input dictionary type is nullable. - public InputDictionaryType(string name, InputType keyType, InputType valueType, IReadOnlyList? decorators = null) : base(name, decorators) + public InputDictionaryType(string name, InputType keyType, InputType valueType) : base(name) { KeyType = keyType; ValueType = valueType; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs index 783f39ac556..795d3178d3b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDurationType.cs @@ -1,13 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { public class InputDurationType : InputType { - public InputDurationType(DurationKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDurationType? baseType, IReadOnlyList? decorators = null) : base(name, decorators) + public InputDurationType(DurationKnownEncoding encode, string name, string crossLanguageDefinitionId, InputPrimitiveType wireType, InputDurationType? baseType) : base(name) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Encode = encode; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs index e902a916585..dde598de30e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumType.cs @@ -7,8 +7,8 @@ namespace Microsoft.Generator.CSharp.Input { public class InputEnumType : InputType { - public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible, IReadOnlyList? decorators = null) - : base(name, decorators) + public InputEnumType(string name, string crossLanguageDefinitionId, string? accessibility, string? deprecated, string description, InputModelTypeUsage usage, InputPrimitiveType valueType, IReadOnlyList values, bool isExtensible) + : base(name) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Accessibility = accessibility; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs index 67feb394046..fa004346ddc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputEnumTypeValue.cs @@ -7,18 +7,17 @@ namespace Microsoft.Generator.CSharp.Input { public class InputEnumTypeValue { - public InputEnumTypeValue(string name, object value, string? description, IReadOnlyList? decorators = null) + public InputEnumTypeValue(string name, object value, string? description) { Name = name; Value = value; Description = description; - Decorators = decorators ?? []; } public string Name { get; } public object Value { get; } public string? Description { get; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); public virtual string GetJsonValueString() => GetValueString(); public string GetValueString() => Value.ToString() ?? string.Empty; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs index b46bfd04576..5f2b455b9a4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputLiteralType.cs @@ -1,13 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { public sealed class InputLiteralType : InputType { - public InputLiteralType(InputType valueType, object value, IReadOnlyList? decorators = null) : base("Literal", decorators) + public InputLiteralType(InputType valueType, object value) : base("Literal") { ValueType = valueType; Value = value; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 36aa233a088..d60570bd71d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input { public class InputModelProperty { - public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList? flattenedNames = null, IReadOnlyList? decorators = null) + public InputModelProperty(string name, string serializedName, string description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList? flattenedNames = null) { Name = name; SerializedName = serializedName; @@ -18,7 +17,6 @@ public InputModelProperty(string name, string serializedName, string description IsReadOnly = isReadOnly; IsDiscriminator = isDiscriminator; FlattenedNames = flattenedNames ?? []; - Decorators = decorators ?? []; } public string Name { get; } @@ -29,6 +27,6 @@ public InputModelProperty(string name, string serializedName, string description public bool IsReadOnly { get; } public bool IsDiscriminator { get; } public IReadOnlyList FlattenedNames { get; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index 90b51d3c97b..41ccb5b299d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -10,8 +10,8 @@ namespace Microsoft.Generator.CSharp.Input public class InputModelType : InputType { // TODO: Follow up issue https://github.com/microsoft/typespec/issues/3619. After https://github.com/Azure/typespec-azure/pull/966 is completed, update this type and remove the "modelAsStruct" parameter. - public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct, IReadOnlyList? decorators = null) - : base(name, decorators) + public InputModelType(string name, string crossLanguageDefinitionId, string? access, string? deprecation, string? description, InputModelTypeUsage usage, IReadOnlyList properties, InputModelType? baseModel, IReadOnlyList derivedModels, string? discriminatorValue, InputModelProperty? discriminatorProperty, IReadOnlyDictionary discriminatedSubtypes, InputType? additionalProperties, bool modelAsStruct) + : base(name) { CrossLanguageDefinitionId = crossLanguageDefinitionId; Access = access; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs index 285892516b9..8e564a3c8b9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputNullableType.cs @@ -1,14 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { public sealed class InputNullableType : InputType { - public InputNullableType(InputType type, IReadOnlyList? decorators = null) : base("nullable", decorators) + public InputNullableType(InputType type) : base("nullable") { Type = type; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs index 4cbf95cdf7f..ab2510036cb 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputOperation.cs @@ -30,8 +30,7 @@ public InputOperation( OperationPaging? paging, bool generateProtocolMethod, bool generateConvenienceMethod, - string crossLanguageDefinitionId, - IReadOnlyList? decorators = null) + string crossLanguageDefinitionId) { Name = name; ResourceName = resourceName; @@ -52,7 +51,6 @@ public InputOperation( GenerateProtocolMethod = generateProtocolMethod; GenerateConvenienceMethod = generateConvenienceMethod; CrossLanguageDefinitionId = crossLanguageDefinitionId; - Decorators = decorators ?? []; } public InputOperation() : this( @@ -74,8 +72,7 @@ public InputOperation() : this( paging: null, generateProtocolMethod: true, generateConvenienceMethod: false, - crossLanguageDefinitionId: string.Empty, - decorators: Array.Empty()) + crossLanguageDefinitionId: string.Empty) { } public string Name { get; internal set; } @@ -97,7 +94,7 @@ public InputOperation() : this( public bool GenerateProtocolMethod { get; internal set; } public bool GenerateConvenienceMethod { get; internal set; } public string CrossLanguageDefinitionId { get; internal set; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); private IReadOnlyDictionary? _examples; internal IReadOnlyDictionary Examples => _examples ??= EnsureExamples(); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs index 71fdbc84101..305bf310b52 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs @@ -23,8 +23,7 @@ public InputParameter( bool skipUrlEncoding, bool explode, string? arraySerializationDelimiter, - string? headerCollectionPrefix, - IReadOnlyList? decorators = null) + string? headerCollectionPrefix) { Name = name; NameInRequest = nameInRequest; @@ -42,7 +41,6 @@ public InputParameter( Explode = explode; ArraySerializationDelimiter = arraySerializationDelimiter; HeaderCollectionPrefix = headerCollectionPrefix; - Decorators = decorators ?? []; } public string Name { get; } @@ -61,6 +59,6 @@ public InputParameter( public bool Explode { get; } public string? ArraySerializationDelimiter { get; } public string? HeaderCollectionPrefix { get; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs index b99620f48ac..374704bf51a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputPrimitiveType.cs @@ -1,25 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { public sealed class InputPrimitiveType : InputType { - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, IReadOnlyList? decorators = null) : base(name, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId) : base(name) { Kind = kind; CrossLanguageDefinitionId = crossLanguageDefinitionId; } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, IReadOnlyList? decorators = null) : this(kind, name, crossLanguageDefinitionId, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode) : this(kind, name, crossLanguageDefinitionId) { Encode = encode; } - public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, InputPrimitiveType? baseType, IReadOnlyList? decorators = null) : this(kind, name, crossLanguageDefinitionId, encode, decorators) + public InputPrimitiveType(InputPrimitiveTypeKind kind, string name, string crossLanguageDefinitionId, string? encode, InputPrimitiveType? baseType) : this(kind, name, crossLanguageDefinitionId, encode) { BaseType = baseType; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs index 715961e750c..347aa08d401 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputType.cs @@ -14,14 +14,13 @@ public abstract class InputType /// Construct a new instance /// /// The name of the input type. - protected InputType(string name, IReadOnlyList? decorators = null) + protected InputType(string name) { Name = name; - Decorators = decorators ?? []; } public string Name { get; internal set; } - public IReadOnlyList Decorators { get; internal set; } + public IReadOnlyList Decorators { get; internal set; } = new List(); internal InputType GetCollectionEquivalent(InputType inputType) { @@ -31,14 +30,18 @@ internal InputType GetCollectionEquivalent(InputType inputType) return new InputArrayType( listType.Name, listType.CrossLanguageDefinitionId, - listType.ValueType.GetCollectionEquivalent(inputType), - listType.Decorators); + listType.ValueType.GetCollectionEquivalent(inputType)) + { + Decorators = listType.Decorators + }; case InputDictionaryType dictionaryType: return new InputDictionaryType( dictionaryType.Name, dictionaryType.KeyType, - dictionaryType.ValueType.GetCollectionEquivalent(inputType), - dictionaryType.Decorators); + dictionaryType.ValueType.GetCollectionEquivalent(inputType)) + { + Decorators = dictionaryType.Decorators + }; default: return inputType; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs index 83f554fb4bf..d66a2c0d8c4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputUnionType.cs @@ -7,7 +7,7 @@ namespace Microsoft.Generator.CSharp.Input { public class InputUnionType : InputType { - public InputUnionType(string name, IReadOnlyList variantTypes, IReadOnlyList? decorators = null) : base(name, decorators) + public InputUnionType(string name, IReadOnlyList variantTypes) : base(name) { VariantTypes = variantTypes; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs index f3150267d08..be7c4d67b6d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs @@ -44,7 +44,8 @@ public static InputArrayType CreateListType(ref Utf8JsonReader reader, string? i } valueType = valueType ?? throw new JsonException("List must have element type"); - var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType, decorators); + var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType); + listType.Decorators = decorators ?? Array.Empty(); if (id != null) { resolver.AddReference(id, listType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs index 838a34b906e..0faec3a96d9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDateTimeType CreateDateTimeType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("DateTime type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType, decorators) + ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? Array.Empty() } : throw new JsonException($"Encoding of DateTime type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs index edd0c86b56b..75d85e27d97 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs @@ -45,7 +45,10 @@ public static InputDictionaryType CreateDictionaryType(ref Utf8JsonReader reader keyType = keyType ?? throw new JsonException("Dictionary must have key type"); valueType = valueType ?? throw new JsonException("Dictionary must have value type"); - var dictType = new InputDictionaryType("Dictionary", keyType, valueType, decorators); + var dictType = new InputDictionaryType("Dictionary", keyType, valueType) + { + Decorators = decorators ?? Array.Empty(), + }; if (id != null) { resolver.AddReference(id, dictType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs index 428f3027129..6ac8e0d3c61 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("Duration type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType, decorators) + ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? Array.Empty() } : throw new JsonException($"Encoding of Duration type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs index 4da775f941d..fc3ccba5684 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs @@ -78,7 +78,10 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id throw new JsonException("The ValueType of an EnumType must be a primitive type."); } - var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable, decorators); + var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable) + { + Decorators = decorators ?? Array.Empty() + }; if (id != null) { resolver.AddReference(id, enumType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs index b277a60da98..7ffd78de59b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs @@ -47,7 +47,7 @@ public static InputEnumTypeValue CreateEnumTypeValue(ref Utf8JsonReader reader, value = value ?? throw new JsonException("EnumValue must have value"); - var enumValue = new InputEnumTypeValue(name, value, description, decorators); + var enumValue = new InputEnumTypeValue(name, value, description) { Decorators = decorators ?? Array.Empty() }; if (id != null) { resolver.AddReference(id, enumValue); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs index 84e0021dd25..82b52a3059b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs @@ -54,7 +54,10 @@ public static InputLiteralType CreateInputLiteralType(ref Utf8JsonReader reader, value = value ?? throw new JsonException("InputConstant must have value"); - var literalType = new InputLiteralType(type, value, decorators); + var literalType = new InputLiteralType(type, value) + { + Decorators = decorators ?? Array.Empty() + }; if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index ee354968d1c..ddddedffeb7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -60,7 +60,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read // description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames, decorators); + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames) { Decorators = decorators ?? Array.Empty() }; if (id != null) { resolver.AddReference(id, property); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 2b6d1e232b0..3719b4ea976 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -42,7 +42,10 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st valueType = valueType ?? throw new JsonException("InputNullableType must have value type"); - var nullableType = new InputNullableType(valueType, decorators); + var nullableType = new InputNullableType(valueType) + { + Decorators = decorators ?? Array.Empty(), + }; if (id != null) { resolver.AddReference(id, nullableType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs index 028dcd5b572..f4ca48ce11d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs @@ -109,8 +109,10 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str skipUrlEncoding: skipUrlEncoding, explode: explode, arraySerializationDelimiter: arraySerializationDelimiter, - headerCollectionPrefix: headerCollectionPrefix, - decorators: decorators); + headerCollectionPrefix: headerCollectionPrefix) + { + Decorators = decorators ?? Array.Empty() + }; if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs index eb5614ca73a..74a3ba5b46e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs @@ -55,7 +55,10 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, throw new JsonException($"Unknown primitive type kind: {kind}"); } - var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType, decorators); + var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType) + { + Decorators = decorators ?? Array.Empty() + }; if (id != null) { resolver.AddReference(id, primitiveType); From d58b79ab90248d081fe1f55fbd94b9588fc4dc7d Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 14 Aug 2024 11:36:40 +0800 Subject: [PATCH 23/26] regen test --- .../http/client/naming/tspCodeModel.json | 192 ++- .../http/payload/xml/tspCodeModel.json | 1332 ++++++++++------- 2 files changed, 933 insertions(+), 591 deletions(-) diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json index 8905113976b..af6d594e47c 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json @@ -12,17 +12,20 @@ "$id": "3", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "Values": [ { "$id": "4", "Name": "EnumValue1", - "Value": "value1" + "Value": "value1", + "Decorators": [] } ], "IsExtensible": true, - "Usage": "Input,Json" + "Usage": "Input,Json", + "Decorators": [] }, { "$id": "5", @@ -33,22 +36,26 @@ "$id": "6", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "Values": [ { "$id": "7", "Name": "ClientEnumValue1", - "Value": "value1" + "Value": "value1", + "Decorators": [] }, { "$id": "8", "Name": "ClientEnumValue2", - "Value": "value2" + "Value": "value2", + "Decorators": [] } ], "IsExtensible": true, - "Usage": "Input,Json" + "Usage": "Input,Json", + "Decorators": [] } ], "Models": [ @@ -69,10 +76,12 @@ "$id": "11", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -93,10 +102,12 @@ "$id": "14", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -117,10 +128,12 @@ "$id": "17", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -141,10 +154,12 @@ "$id": "20", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -165,10 +180,12 @@ "$id": "23", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } @@ -234,7 +251,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.operation" + "CrossLanguageDefinitionId": "Client.Naming.operation", + "Decorators": [] }, { "$id": "31", @@ -253,7 +271,8 @@ "$id": "33", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "Location": "Query", "IsApiVersion": false, @@ -261,7 +280,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -282,7 +302,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.parameter" + "CrossLanguageDefinitionId": "Client.Naming.parameter", + "Decorators": [] }, { "$id": "35", @@ -305,9 +326,11 @@ "$id": "38", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -315,7 +338,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "39", @@ -330,7 +354,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -354,7 +379,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Property.client" + "CrossLanguageDefinitionId": "Client.Naming.Property.client", + "Decorators": [] }, { "$id": "41", @@ -377,9 +403,11 @@ "$id": "44", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -387,7 +415,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "45", @@ -402,7 +431,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -426,7 +456,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Property.language" + "CrossLanguageDefinitionId": "Client.Naming.Property.language", + "Decorators": [] }, { "$id": "47", @@ -449,9 +480,11 @@ "$id": "50", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -459,7 +492,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "51", @@ -474,7 +508,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -498,7 +533,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Property.compatibleWithEncodedName" + "CrossLanguageDefinitionId": "Client.Naming.Property.compatibleWithEncodedName", + "Decorators": [] }, { "$id": "53", @@ -517,7 +553,8 @@ "$id": "55", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -525,7 +562,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -546,7 +584,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Header.request" + "CrossLanguageDefinitionId": "Client.Naming.Header.request", + "Decorators": [] }, { "$id": "57", @@ -574,7 +613,8 @@ "$id": "60", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] } } ], @@ -588,7 +628,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Header.response" + "CrossLanguageDefinitionId": "Client.Naming.Header.response", + "Decorators": [] } ], "Protocol": { @@ -598,7 +639,8 @@ { "$ref": "26" } - ] + ], + "Decorators": [] }, { "$id": "62", @@ -652,9 +694,11 @@ "$id": "70", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -662,7 +706,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "71", @@ -677,7 +722,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -701,7 +747,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Model.client" + "CrossLanguageDefinitionId": "Client.Naming.Model.client", + "Decorators": [] }, { "$id": "73", @@ -724,9 +771,11 @@ "$id": "76", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -734,7 +783,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "77", @@ -749,7 +799,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -773,7 +824,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.Model.language" + "CrossLanguageDefinitionId": "Client.Naming.Model.language", + "Decorators": [] } ], "Protocol": { @@ -784,7 +836,8 @@ { "$ref": "64" } - ] + ], + "Decorators": [] }, { "$id": "80", @@ -838,9 +891,11 @@ "$id": "88", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -848,7 +903,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "89", @@ -863,7 +919,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -887,7 +944,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.UnionEnum.unionEnumName" + "CrossLanguageDefinitionId": "Client.Naming.UnionEnum.unionEnumName", + "Decorators": [] }, { "$id": "91", @@ -910,9 +968,11 @@ "$id": "94", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/json" + "Value": "application/json", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -920,7 +980,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { "$id": "95", @@ -935,7 +996,8 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ @@ -959,7 +1021,8 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Client.Naming.UnionEnum.unionEnumMemberName" + "CrossLanguageDefinitionId": "Client.Naming.UnionEnum.unionEnumMemberName", + "Decorators": [] } ], "Protocol": { @@ -970,7 +1033,8 @@ { "$ref": "82" } - ] + ], + "Decorators": [] } ] } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json index 655b5abd7cc..65db89eacbd 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json @@ -36,10 +36,12 @@ "$id": "6", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "7", @@ -50,15 +52,18 @@ "$id": "8", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { "$id": "9", @@ -73,12 +78,15 @@ "$id": "11", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -106,17 +114,21 @@ "$id": "15", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "ValueType": { "$id": "16", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" - } + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, @@ -138,29 +150,49 @@ "$id": "19", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "20", + "name": "TypeSpec.Xml.@attribute", + "arguments": { + "$id": "21" + } + } + ] }, { - "$id": "20", + "$id": "22", "Name": "content", "SerializedName": "content", "Description": "", "Type": { - "$id": "21", + "$id": "23", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "24", + "name": "TypeSpec.Xml.@unwrapped", + "arguments": { + "$id": "25" + } + } + ] } ] }, { - "$id": "22", + "$id": "26", "Kind": "model", "Name": "ModelWithEmptyArray", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArray", @@ -169,26 +201,28 @@ "Decorators": [], "Properties": [ { - "$id": "23", + "$id": "27", "Name": "items", "SerializedName": "items", "Description": "", "Type": { - "$id": "24", + "$id": "28", "Kind": "array", "Name": "ArraySimpleModel", "ValueType": { "$ref": "4" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, { - "$id": "25", + "$id": "29", "Kind": "model", "Name": "ModelWithRenamedFields", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFields", @@ -196,17 +230,17 @@ "Description": "Contains fields of the same type that have different XML representation.", "Decorators": [ { - "$id": "26", + "$id": "30", "name": "TypeSpec.Xml.@name", "arguments": { - "$id": "27", + "$id": "31", "name": "ModelWithRenamedFieldsSrc" } } ], "Properties": [ { - "$id": "28", + "$id": "32", "Name": "inputData", "SerializedName": "inputData", "Description": "", @@ -214,10 +248,20 @@ "$ref": "4" }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "33", + "name": "TypeSpec.Xml.@name", + "arguments": { + "$id": "34", + "name": "InputData" + } + } + ] }, { - "$id": "29", + "$id": "35", "Name": "outputData", "SerializedName": "outputData", "Description": "", @@ -225,12 +269,22 @@ "$ref": "4" }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "36", + "name": "TypeSpec.Xml.@name", + "arguments": { + "$id": "37", + "name": "OutputData" + } + } + ] } ] }, { - "$id": "30", + "$id": "38", "Kind": "model", "Name": "ModelWithRenamedArrays", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArrays", @@ -239,49 +293,80 @@ "Decorators": [], "Properties": [ { - "$id": "31", + "$id": "39", "Name": "colors", "SerializedName": "colors", "Description": "", "Type": { - "$id": "32", + "$id": "40", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "33", + "$id": "41", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "42", + "name": "TypeSpec.Xml.@unwrapped", + "arguments": { + "$id": "43" + } + }, + { + "$id": "44", + "name": "TypeSpec.Xml.@name", + "arguments": { + "$id": "45", + "name": "Colors" + } + } + ] }, { - "$id": "34", + "$id": "46", "Name": "counts", "SerializedName": "counts", "Description": "", "Type": { - "$id": "35", + "$id": "47", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "36", + "$id": "48", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "49", + "name": "TypeSpec.Xml.@name", + "arguments": { + "$id": "50", + "name": "Counts" + } + } + ] } ] }, { - "$id": "37", + "$id": "51", "Kind": "model", "Name": "ModelWithUnwrappedArray", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArray", @@ -290,49 +375,63 @@ "Decorators": [], "Properties": [ { - "$id": "38", + "$id": "52", "Name": "colors", "SerializedName": "colors", "Description": "", "Type": { - "$id": "39", + "$id": "53", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "40", + "$id": "54", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "55", + "name": "TypeSpec.Xml.@unwrapped", + "arguments": { + "$id": "56" + } + } + ] }, { - "$id": "41", + "$id": "57", "Name": "counts", "SerializedName": "counts", "Description": "", "Type": { - "$id": "42", + "$id": "58", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "43", + "$id": "59", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, { - "$id": "44", + "$id": "60", "Kind": "model", "Name": "ModelWithAttributes", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes", @@ -341,51 +440,73 @@ "Decorators": [], "Properties": [ { - "$id": "45", + "$id": "61", "Name": "id1", "SerializedName": "id1", "Description": "", "Type": { - "$id": "46", + "$id": "62", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "63", + "name": "TypeSpec.Xml.@attribute", + "arguments": { + "$id": "64" + } + } + ] }, { - "$id": "47", + "$id": "65", "Name": "id2", "SerializedName": "id2", "Description": "", "Type": { - "$id": "48", + "$id": "66", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [ + { + "$id": "67", + "name": "TypeSpec.Xml.@attribute", + "arguments": { + "$id": "68" + } + } + ] }, { - "$id": "49", + "$id": "69", "Name": "enabled", "SerializedName": "enabled", "Description": "", "Type": { - "$id": "50", + "$id": "70", "Kind": "boolean", "Name": "boolean", - "CrossLanguageDefinitionId": "TypeSpec.boolean" + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, { - "$id": "51", + "$id": "71", "Kind": "model", "Name": "ModelWithOptionalField", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField", @@ -394,37 +515,41 @@ "Decorators": [], "Properties": [ { - "$id": "52", + "$id": "72", "Name": "item", "SerializedName": "item", "Description": "", "Type": { - "$id": "53", + "$id": "73", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { - "$id": "54", + "$id": "74", "Name": "value", "SerializedName": "value", "Description": "", "Type": { - "$id": "55", + "$id": "75", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, "IsRequired": false, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, { - "$id": "56", + "$id": "76", "Kind": "model", "Name": "ModelWithArrayOfModel", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModel", @@ -433,26 +558,28 @@ "Decorators": [], "Properties": [ { - "$id": "57", + "$id": "77", "Name": "items", "SerializedName": "items", "Description": "", "Type": { - "$id": "58", + "$id": "78", "Kind": "array", "Name": "ArraySimpleModel", "ValueType": { "$ref": "4" }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] }, { - "$id": "59", + "$id": "79", "Kind": "model", "Name": "ModelWithSimpleArrays", "CrossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays", @@ -461,64 +588,70 @@ "Decorators": [], "Properties": [ { - "$id": "60", + "$id": "80", "Name": "colors", "SerializedName": "colors", "Description": "", "Type": { - "$id": "61", + "$id": "81", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "62", + "$id": "82", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] }, { - "$id": "63", + "$id": "83", "Name": "counts", "SerializedName": "counts", "Description": "", "Type": { - "$id": "64", + "$id": "84", "Kind": "array", "Name": "Array", "ValueType": { - "$id": "65", + "$id": "85", "Kind": "int32", "Name": "int32", - "CrossLanguageDefinitionId": "TypeSpec.int32" + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] }, - "CrossLanguageDefinitionId": "TypeSpec.Array" + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] }, "IsRequired": true, - "IsReadOnly": false + "IsReadOnly": false, + "Decorators": [] } ] } ], "Clients": [ { - "$id": "66", + "$id": "86", "Name": "XmlClient", "Description": "Sends and receives bodies in XML format.", "Operations": [], "Protocol": { - "$id": "67" + "$id": "87" }, "Parameters": [ { - "$id": "68", + "$id": "88", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "69", + "$id": "89", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -533,9 +666,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "70", + "$id": "90", "Type": { - "$id": "71", + "$id": "91", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -543,25 +676,26 @@ "Value": "http://localhost:3000" } } - ] + ], + "Decorators": [] }, { - "$id": "72", + "$id": "92", "Name": "SimpleModelValue", "Description": "Operations for the SimpleModel type.", "Operations": [ { - "$id": "73", + "$id": "93", "Name": "get", "ResourceName": "SimpleModelValue", "Accessibility": "public", "Parameters": [ { - "$id": "74", + "$id": "94", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "75", + "$id": "95", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -576,9 +710,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "76", + "$id": "96", "Type": { - "$id": "77", + "$id": "97", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -587,19 +721,21 @@ } }, { - "$id": "78", + "$id": "98", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "79", + "$id": "99", "Kind": "constant", "ValueType": { - "$id": "80", + "$id": "100", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -607,12 +743,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "81", + "$id": "101", "StatusCodes": [ 200 ], @@ -622,19 +759,21 @@ "BodyMediaType": "Json", "Headers": [ { - "$id": "82", + "$id": "102", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "83", + "$id": "103", "Kind": "constant", "ValueType": { - "$id": "84", + "$id": "104", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -651,31 +790,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get", + "Decorators": [] }, { - "$id": "85", + "$id": "105", "Name": "put", "ResourceName": "SimpleModelValue", "Accessibility": "public", "Parameters": [ { - "$ref": "74" + "$ref": "94" }, { - "$id": "86", + "$id": "106", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "87", + "$id": "107", "Kind": "constant", "ValueType": { - "$id": "88", + "$id": "108", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -683,10 +825,11 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "89", + "$id": "109", "Name": "input", "NameInRequest": "input", "Type": { @@ -698,12 +841,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "90", + "$id": "110", "StatusCodes": [ 204 ], @@ -722,36 +866,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "91" + "$id": "111" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "74" + "$ref": "94" } - ] + ], + "Decorators": [] }, { - "$id": "92", + "$id": "112", "Name": "ModelWithSimpleArraysValue", "Description": "Operations for the ModelWithSimpleArrays type.", "Operations": [ { - "$id": "93", + "$id": "113", "Name": "get", "ResourceName": "ModelWithSimpleArraysValue", "Accessibility": "public", "Parameters": [ { - "$id": "94", + "$id": "114", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "95", + "$id": "115", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -766,9 +912,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "96", + "$id": "116", "Type": { - "$id": "97", + "$id": "117", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -777,19 +923,21 @@ } }, { - "$id": "98", + "$id": "118", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "99", + "$id": "119", "Kind": "constant", "ValueType": { - "$id": "100", + "$id": "120", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -797,34 +945,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "101", + "$id": "121", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "59" + "$ref": "79" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "102", + "$id": "122", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "103", + "$id": "123", "Kind": "constant", "ValueType": { - "$id": "104", + "$id": "124", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -841,31 +992,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get", + "Decorators": [] }, { - "$id": "105", + "$id": "125", "Name": "put", "ResourceName": "ModelWithSimpleArraysValue", "Accessibility": "public", "Parameters": [ { - "$ref": "94" + "$ref": "114" }, { - "$id": "106", + "$id": "126", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "107", + "$id": "127", "Kind": "constant", "ValueType": { - "$id": "108", + "$id": "128", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -873,14 +1027,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "109", + "$id": "129", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "59" + "$ref": "79" }, "Location": "Body", "IsApiVersion": false, @@ -888,12 +1043,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "110", + "$id": "130", "StatusCodes": [ 204 ], @@ -912,36 +1068,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "111" + "$id": "131" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "94" + "$ref": "114" } - ] + ], + "Decorators": [] }, { - "$id": "112", + "$id": "132", "Name": "ModelWithArrayOfModelValue", "Description": "Operations for the ModelWithArrayOfModel type.", "Operations": [ { - "$id": "113", + "$id": "133", "Name": "get", "ResourceName": "ModelWithArrayOfModelValue", "Accessibility": "public", "Parameters": [ { - "$id": "114", + "$id": "134", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "115", + "$id": "135", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -956,9 +1114,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "116", + "$id": "136", "Type": { - "$id": "117", + "$id": "137", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -967,19 +1125,21 @@ } }, { - "$id": "118", + "$id": "138", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "119", + "$id": "139", "Kind": "constant", "ValueType": { - "$id": "120", + "$id": "140", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -987,34 +1147,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "121", + "$id": "141", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "56" + "$ref": "76" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "122", + "$id": "142", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "123", + "$id": "143", "Kind": "constant", "ValueType": { - "$id": "124", + "$id": "144", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1031,31 +1194,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get", + "Decorators": [] }, { - "$id": "125", + "$id": "145", "Name": "put", "ResourceName": "ModelWithArrayOfModelValue", "Accessibility": "public", "Parameters": [ { - "$ref": "114" + "$ref": "134" }, { - "$id": "126", + "$id": "146", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "127", + "$id": "147", "Kind": "constant", "ValueType": { - "$id": "128", + "$id": "148", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1063,14 +1229,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "129", + "$id": "149", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "56" + "$ref": "76" }, "Location": "Body", "IsApiVersion": false, @@ -1078,12 +1245,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "130", + "$id": "150", "StatusCodes": [ 204 ], @@ -1102,36 +1270,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "131" + "$id": "151" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "114" + "$ref": "134" } - ] + ], + "Decorators": [] }, { - "$id": "132", + "$id": "152", "Name": "ModelWithOptionalFieldValue", "Description": "Operations for the ModelWithOptionalField type.", "Operations": [ { - "$id": "133", + "$id": "153", "Name": "get", "ResourceName": "ModelWithOptionalFieldValue", "Accessibility": "public", "Parameters": [ { - "$id": "134", + "$id": "154", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "135", + "$id": "155", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -1146,9 +1316,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "136", + "$id": "156", "Type": { - "$id": "137", + "$id": "157", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -1157,19 +1327,21 @@ } }, { - "$id": "138", + "$id": "158", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "139", + "$id": "159", "Kind": "constant", "ValueType": { - "$id": "140", + "$id": "160", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1177,34 +1349,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "141", + "$id": "161", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "51" + "$ref": "71" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "142", + "$id": "162", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "143", + "$id": "163", "Kind": "constant", "ValueType": { - "$id": "144", + "$id": "164", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1221,31 +1396,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get", + "Decorators": [] }, { - "$id": "145", + "$id": "165", "Name": "put", "ResourceName": "ModelWithOptionalFieldValue", "Accessibility": "public", "Parameters": [ { - "$ref": "134" + "$ref": "154" }, { - "$id": "146", + "$id": "166", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "147", + "$id": "167", "Kind": "constant", "ValueType": { - "$id": "148", + "$id": "168", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1253,14 +1431,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "149", + "$id": "169", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "51" + "$ref": "71" }, "Location": "Body", "IsApiVersion": false, @@ -1268,12 +1447,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "150", + "$id": "170", "StatusCodes": [ 204 ], @@ -1292,36 +1472,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "151" + "$id": "171" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "134" + "$ref": "154" } - ] + ], + "Decorators": [] }, { - "$id": "152", + "$id": "172", "Name": "ModelWithAttributesValue", "Description": "Operations for the ModelWithAttributes type.", "Operations": [ { - "$id": "153", + "$id": "173", "Name": "get", "ResourceName": "ModelWithAttributesValue", "Accessibility": "public", "Parameters": [ { - "$id": "154", + "$id": "174", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "155", + "$id": "175", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -1336,9 +1518,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "156", + "$id": "176", "Type": { - "$id": "157", + "$id": "177", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -1347,19 +1529,21 @@ } }, { - "$id": "158", + "$id": "178", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "159", + "$id": "179", "Kind": "constant", "ValueType": { - "$id": "160", + "$id": "180", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1367,34 +1551,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "161", + "$id": "181", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "44" + "$ref": "60" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "162", + "$id": "182", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "163", + "$id": "183", "Kind": "constant", "ValueType": { - "$id": "164", + "$id": "184", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1411,31 +1598,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get", + "Decorators": [] }, { - "$id": "165", + "$id": "185", "Name": "put", "ResourceName": "ModelWithAttributesValue", "Accessibility": "public", "Parameters": [ { - "$ref": "154" + "$ref": "174" }, { - "$id": "166", + "$id": "186", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "167", + "$id": "187", "Kind": "constant", "ValueType": { - "$id": "168", + "$id": "188", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1443,14 +1633,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "169", + "$id": "189", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "44" + "$ref": "60" }, "Location": "Body", "IsApiVersion": false, @@ -1458,12 +1649,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "170", + "$id": "190", "StatusCodes": [ 204 ], @@ -1482,36 +1674,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "171" + "$id": "191" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "154" + "$ref": "174" } - ] + ], + "Decorators": [] }, { - "$id": "172", + "$id": "192", "Name": "ModelWithUnwrappedArrayValue", "Description": "Operations for the ModelWithUnwrappedArray type.", "Operations": [ { - "$id": "173", + "$id": "193", "Name": "get", "ResourceName": "ModelWithUnwrappedArrayValue", "Accessibility": "public", "Parameters": [ { - "$id": "174", + "$id": "194", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "175", + "$id": "195", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -1526,9 +1720,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "176", + "$id": "196", "Type": { - "$id": "177", + "$id": "197", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -1537,19 +1731,21 @@ } }, { - "$id": "178", + "$id": "198", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "179", + "$id": "199", "Kind": "constant", "ValueType": { - "$id": "180", + "$id": "200", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1557,34 +1753,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "181", + "$id": "201", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "37" + "$ref": "51" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "182", + "$id": "202", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "183", + "$id": "203", "Kind": "constant", "ValueType": { - "$id": "184", + "$id": "204", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1601,31 +1800,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get", + "Decorators": [] }, { - "$id": "185", + "$id": "205", "Name": "put", "ResourceName": "ModelWithUnwrappedArrayValue", "Accessibility": "public", "Parameters": [ { - "$ref": "174" + "$ref": "194" }, { - "$id": "186", + "$id": "206", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "187", + "$id": "207", "Kind": "constant", "ValueType": { - "$id": "188", + "$id": "208", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1633,14 +1835,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "189", + "$id": "209", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "37" + "$ref": "51" }, "Location": "Body", "IsApiVersion": false, @@ -1648,12 +1851,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "190", + "$id": "210", "StatusCodes": [ 204 ], @@ -1672,36 +1876,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "191" + "$id": "211" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "174" + "$ref": "194" } - ] + ], + "Decorators": [] }, { - "$id": "192", + "$id": "212", "Name": "ModelWithRenamedArraysValue", "Description": "Operations for the ModelWithRenamedArrays type.", "Operations": [ { - "$id": "193", + "$id": "213", "Name": "get", "ResourceName": "ModelWithRenamedArraysValue", "Accessibility": "public", "Parameters": [ { - "$id": "194", + "$id": "214", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "195", + "$id": "215", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -1716,9 +1922,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "196", + "$id": "216", "Type": { - "$id": "197", + "$id": "217", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -1727,19 +1933,21 @@ } }, { - "$id": "198", + "$id": "218", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "199", + "$id": "219", "Kind": "constant", "ValueType": { - "$id": "200", + "$id": "220", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1747,34 +1955,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "201", + "$id": "221", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "30" + "$ref": "38" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "202", + "$id": "222", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "203", + "$id": "223", "Kind": "constant", "ValueType": { - "$id": "204", + "$id": "224", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1791,31 +2002,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get", + "Decorators": [] }, { - "$id": "205", + "$id": "225", "Name": "put", "ResourceName": "ModelWithRenamedArraysValue", "Accessibility": "public", "Parameters": [ { - "$ref": "194" + "$ref": "214" }, { - "$id": "206", + "$id": "226", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "207", + "$id": "227", "Kind": "constant", "ValueType": { - "$id": "208", + "$id": "228", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1823,14 +2037,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "209", + "$id": "229", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "30" + "$ref": "38" }, "Location": "Body", "IsApiVersion": false, @@ -1838,12 +2053,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "210", + "$id": "230", "StatusCodes": [ 204 ], @@ -1862,36 +2078,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "211" + "$id": "231" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "194" + "$ref": "214" } - ] + ], + "Decorators": [] }, { - "$id": "212", + "$id": "232", "Name": "ModelWithRenamedFieldsValue", "Description": "Operations for the ModelWithRenamedFields type.", "Operations": [ { - "$id": "213", + "$id": "233", "Name": "get", "ResourceName": "ModelWithRenamedFieldsValue", "Accessibility": "public", "Parameters": [ { - "$id": "214", + "$id": "234", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "215", + "$id": "235", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -1906,9 +2124,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "216", + "$id": "236", "Type": { - "$id": "217", + "$id": "237", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -1917,19 +2135,21 @@ } }, { - "$id": "218", + "$id": "238", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "219", + "$id": "239", "Kind": "constant", "ValueType": { - "$id": "220", + "$id": "240", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -1937,34 +2157,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "221", + "$id": "241", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "25" + "$ref": "29" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "222", + "$id": "242", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "223", + "$id": "243", "Kind": "constant", "ValueType": { - "$id": "224", + "$id": "244", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -1981,31 +2204,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get", + "Decorators": [] }, { - "$id": "225", + "$id": "245", "Name": "put", "ResourceName": "ModelWithRenamedFieldsValue", "Accessibility": "public", "Parameters": [ { - "$ref": "214" + "$ref": "234" }, { - "$id": "226", + "$id": "246", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "227", + "$id": "247", "Kind": "constant", "ValueType": { - "$id": "228", + "$id": "248", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2013,14 +2239,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "229", + "$id": "249", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "25" + "$ref": "29" }, "Location": "Body", "IsApiVersion": false, @@ -2028,12 +2255,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "230", + "$id": "250", "StatusCodes": [ 204 ], @@ -2052,36 +2280,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "231" + "$id": "251" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "214" + "$ref": "234" } - ] + ], + "Decorators": [] }, { - "$id": "232", + "$id": "252", "Name": "ModelWithEmptyArrayValue", "Description": "Operations for the ModelWithEmptyArray type.", "Operations": [ { - "$id": "233", + "$id": "253", "Name": "get", "ResourceName": "ModelWithEmptyArrayValue", "Accessibility": "public", "Parameters": [ { - "$id": "234", + "$id": "254", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "235", + "$id": "255", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -2096,9 +2326,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "236", + "$id": "256", "Type": { - "$id": "237", + "$id": "257", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -2107,19 +2337,21 @@ } }, { - "$id": "238", + "$id": "258", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "239", + "$id": "259", "Kind": "constant", "ValueType": { - "$id": "240", + "$id": "260", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2127,34 +2359,37 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "241", + "$id": "261", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "22" + "$ref": "26" }, "BodyMediaType": "Json", "Headers": [ { - "$id": "242", + "$id": "262", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "243", + "$id": "263", "Kind": "constant", "ValueType": { - "$id": "244", + "$id": "264", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -2171,31 +2406,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get", + "Decorators": [] }, { - "$id": "245", + "$id": "265", "Name": "put", "ResourceName": "ModelWithEmptyArrayValue", "Accessibility": "public", "Parameters": [ { - "$ref": "234" + "$ref": "254" }, { - "$id": "246", + "$id": "266", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "247", + "$id": "267", "Kind": "constant", "ValueType": { - "$id": "248", + "$id": "268", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2203,14 +2441,15 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "249", + "$id": "269", "Name": "input", "NameInRequest": "input", "Type": { - "$ref": "22" + "$ref": "26" }, "Location": "Body", "IsApiVersion": false, @@ -2218,12 +2457,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "250", + "$id": "270", "StatusCodes": [ 204 ], @@ -2242,36 +2482,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "251" + "$id": "271" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "234" + "$ref": "254" } - ] + ], + "Decorators": [] }, { - "$id": "252", + "$id": "272", "Name": "ModelWithTextValue", "Description": "Operations for the ModelWithText type.", "Operations": [ { - "$id": "253", + "$id": "273", "Name": "get", "ResourceName": "ModelWithTextValue", "Accessibility": "public", "Parameters": [ { - "$id": "254", + "$id": "274", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "255", + "$id": "275", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -2286,9 +2528,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "256", + "$id": "276", "Type": { - "$id": "257", + "$id": "277", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -2297,19 +2539,21 @@ } }, { - "$id": "258", + "$id": "278", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "259", + "$id": "279", "Kind": "constant", "ValueType": { - "$id": "260", + "$id": "280", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2317,12 +2561,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "261", + "$id": "281", "StatusCodes": [ 200 ], @@ -2332,19 +2577,21 @@ "BodyMediaType": "Json", "Headers": [ { - "$id": "262", + "$id": "282", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "263", + "$id": "283", "Kind": "constant", "ValueType": { - "$id": "264", + "$id": "284", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -2361,31 +2608,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get", + "Decorators": [] }, { - "$id": "265", + "$id": "285", "Name": "put", "ResourceName": "ModelWithTextValue", "Accessibility": "public", "Parameters": [ { - "$ref": "254" + "$ref": "274" }, { - "$id": "266", + "$id": "286", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "267", + "$id": "287", "Kind": "constant", "ValueType": { - "$id": "268", + "$id": "288", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2393,10 +2643,11 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "269", + "$id": "289", "Name": "input", "NameInRequest": "input", "Type": { @@ -2408,12 +2659,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "270", + "$id": "290", "StatusCodes": [ 204 ], @@ -2432,36 +2684,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "271" + "$id": "291" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "254" + "$ref": "274" } - ] + ], + "Decorators": [] }, { - "$id": "272", + "$id": "292", "Name": "ModelWithDictionaryValue", "Description": "Operations for the ModelWithDictionary type.", "Operations": [ { - "$id": "273", + "$id": "293", "Name": "get", "ResourceName": "ModelWithDictionaryValue", "Accessibility": "public", "Parameters": [ { - "$id": "274", + "$id": "294", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "275", + "$id": "295", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -2476,9 +2730,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "276", + "$id": "296", "Type": { - "$id": "277", + "$id": "297", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -2487,19 +2741,21 @@ } }, { - "$id": "278", + "$id": "298", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "279", + "$id": "299", "Kind": "constant", "ValueType": { - "$id": "280", + "$id": "300", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2507,12 +2763,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "281", + "$id": "301", "StatusCodes": [ 200 ], @@ -2522,19 +2779,21 @@ "BodyMediaType": "Json", "Headers": [ { - "$id": "282", + "$id": "302", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "283", + "$id": "303", "Kind": "constant", "ValueType": { - "$id": "284", + "$id": "304", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -2551,31 +2810,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get", + "Decorators": [] }, { - "$id": "285", + "$id": "305", "Name": "put", "ResourceName": "ModelWithDictionaryValue", "Accessibility": "public", "Parameters": [ { - "$ref": "274" + "$ref": "294" }, { - "$id": "286", + "$id": "306", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "287", + "$id": "307", "Kind": "constant", "ValueType": { - "$id": "288", + "$id": "308", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2583,10 +2845,11 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "289", + "$id": "309", "Name": "input", "NameInRequest": "input", "Type": { @@ -2598,12 +2861,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "290", + "$id": "310", "StatusCodes": [ 204 ], @@ -2622,36 +2886,38 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "291" + "$id": "311" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "274" + "$ref": "294" } - ] + ], + "Decorators": [] }, { - "$id": "292", + "$id": "312", "Name": "ModelWithEncodedNamesValue", "Description": "Operations for the ModelWithEncodedNames type.", "Operations": [ { - "$id": "293", + "$id": "313", "Name": "get", "ResourceName": "ModelWithEncodedNamesValue", "Accessibility": "public", "Parameters": [ { - "$id": "294", + "$id": "314", "Name": "endpoint", "NameInRequest": "endpoint", "Type": { - "$id": "295", + "$id": "315", "Kind": "url", "Name": "url", "CrossLanguageDefinitionId": "TypeSpec.url" @@ -2666,9 +2932,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "296", + "$id": "316", "Type": { - "$id": "297", + "$id": "317", "Kind": "string", "Name": "string", "CrossLanguageDefinitionId": "TypeSpec.string" @@ -2677,19 +2943,21 @@ } }, { - "$id": "298", + "$id": "318", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "299", + "$id": "319", "Kind": "constant", "ValueType": { - "$id": "300", + "$id": "320", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2697,12 +2965,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] } ], "Responses": [ { - "$id": "301", + "$id": "321", "StatusCodes": [ 200 ], @@ -2712,19 +2981,21 @@ "BodyMediaType": "Json", "Headers": [ { - "$id": "302", + "$id": "322", "Name": "contentType", "NameInResponse": "content-type", "Type": { - "$id": "303", + "$id": "323", "Kind": "constant", "ValueType": { - "$id": "304", + "$id": "324", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] } } ], @@ -2741,31 +3012,34 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get", + "Decorators": [] }, { - "$id": "305", + "$id": "325", "Name": "put", "ResourceName": "ModelWithEncodedNamesValue", "Accessibility": "public", "Parameters": [ { - "$ref": "294" + "$ref": "314" }, { - "$id": "306", + "$id": "326", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "307", + "$id": "327", "Kind": "constant", "ValueType": { - "$id": "308", + "$id": "328", "Kind": "string", "Name": "string", - "CrossLanguageDefinitionId": "TypeSpec.string" + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] }, - "Value": "application/xml" + "Value": "application/xml", + "Decorators": [] }, "Location": "Header", "IsApiVersion": false, @@ -2773,10 +3047,11 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Constant" + "Kind": "Constant", + "Decorators": [] }, { - "$id": "309", + "$id": "329", "Name": "input", "NameInRequest": "input", "Type": { @@ -2788,12 +3063,13 @@ "IsEndpoint": false, "Explode": false, "IsRequired": true, - "Kind": "Method" + "Kind": "Method", + "Decorators": [] } ], "Responses": [ { - "$id": "310", + "$id": "330", "StatusCodes": [ 204 ], @@ -2812,18 +3088,20 @@ "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true, - "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put" + "CrossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put", + "Decorators": [] } ], "Protocol": { - "$id": "311" + "$id": "331" }, "Parent": "XmlClient", "Parameters": [ { - "$ref": "294" + "$ref": "314" } - ] + ], + "Decorators": [] } ] } From ad3fa9ea318fea20ebd18d84237843275b551eb5 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 14 Aug 2024 11:47:51 +0800 Subject: [PATCH 24/26] remove unused import --- .../src/InputTypes/InputDateTimeType.cs | 2 -- .../src/InputTypes/InputModelType.cs | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs index 5a532379844..818d8febd7b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputDateTimeType.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; - namespace Microsoft.Generator.CSharp.Input { public class InputDateTimeType : InputType diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index 41ccb5b299d..ae0753a8337 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Linq; namespace Microsoft.Generator.CSharp.Input { From 9d4308ad3cb7c5f2ec960e155e950a29447eec9f Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Wed, 14 Aug 2024 15:08:44 +0800 Subject: [PATCH 25/26] use simple empty array --- .../Serialization/TypeSpecInputArrayTypeConverter.cs | 6 ++++-- .../Serialization/TypeSpecInputClientConverter.cs | 2 +- .../Serialization/TypeSpecInputDateTimeTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputDictionaryTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputDurationTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputEnumTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputEnumTypeValueConverter.cs | 2 +- .../Serialization/TypeSpecInputLiteralTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputModelPropertyConverter.cs | 2 +- .../Serialization/TypeSpecInputNullableTypeConverter.cs | 2 +- .../Serialization/TypeSpecInputOperationConverter.cs | 2 +- .../Serialization/TypeSpecInputParameterConverter.cs | 2 +- .../Serialization/TypeSpecInputPrimitiveTypeConverter.cs | 2 +- 13 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs index be7c4d67b6d..d7112dcd4f7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputArrayTypeConverter.cs @@ -44,8 +44,10 @@ public static InputArrayType CreateListType(ref Utf8JsonReader reader, string? i } valueType = valueType ?? throw new JsonException("List must have element type"); - var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType); - listType.Decorators = decorators ?? Array.Empty(); + var listType = new InputArrayType(name ?? "Array", crossLanguageDefinitionId ?? string.Empty, valueType) + { + Decorators = decorators ?? [] + }; if (id != null) { resolver.AddReference(id, listType); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs index c31f878601e..7df4c4b773f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputClientConverter.cs @@ -61,7 +61,7 @@ public override void Write(Utf8JsonWriter writer, InputClient value, JsonSeriali client.Operations = operations ?? Array.Empty(); client.Parameters = parameters ?? Array.Empty(); client.Parent = parent; - client.Decorators = decorators ?? Array.Empty(); + client.Decorators = decorators ?? []; return client; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs index 0faec3a96d9..37949a95f01 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDateTimeTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDateTimeType CreateDateTimeType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("DateTime type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? Array.Empty() } + ? new InputDateTimeType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? [] } : throw new JsonException($"Encoding of DateTime type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs index 75d85e27d97..f0695477116 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDictionaryTypeConverter.cs @@ -47,7 +47,7 @@ public static InputDictionaryType CreateDictionaryType(ref Utf8JsonReader reader var dictType = new InputDictionaryType("Dictionary", keyType, valueType) { - Decorators = decorators ?? Array.Empty(), + Decorators = decorators ?? [], }; if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs index 6ac8e0d3c61..277c55901cd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDurationTypeConverter.cs @@ -57,7 +57,7 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st encode = encode ?? throw new JsonException("Duration type must have encoding"); var dateTimeType = Enum.TryParse(encode, ignoreCase: true, out var encodeKind) - ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? Array.Empty() } + ? new InputDurationType(encodeKind, name, crossLanguageDefinitionId, wireType, baseType) { Decorators = decorators ?? [] } : throw new JsonException($"Encoding of Duration type {encode} is unknown."); if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs index fc3ccba5684..9d3511ea851 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeConverter.cs @@ -80,7 +80,7 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id var enumType = new InputEnumType(name, crossLanguageDefinitionId ?? string.Empty, accessibility, deprecated, description!, usage, inputValueType, NormalizeValues(values, inputValueType), isExtendable) { - Decorators = decorators ?? Array.Empty() + Decorators = decorators ?? [] }; if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs index 7ffd78de59b..01358444046 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputEnumTypeValueConverter.cs @@ -47,7 +47,7 @@ public static InputEnumTypeValue CreateEnumTypeValue(ref Utf8JsonReader reader, value = value ?? throw new JsonException("EnumValue must have value"); - var enumValue = new InputEnumTypeValue(name, value, description) { Decorators = decorators ?? Array.Empty() }; + var enumValue = new InputEnumTypeValue(name, value, description) { Decorators = decorators ?? [] }; if (id != null) { resolver.AddReference(id, enumValue); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs index 82b52a3059b..b97fa528697 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputLiteralTypeConverter.cs @@ -56,7 +56,7 @@ public static InputLiteralType CreateInputLiteralType(ref Utf8JsonReader reader, var literalType = new InputLiteralType(type, value) { - Decorators = decorators ?? Array.Empty() + Decorators = decorators ?? [] }; if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index ddddedffeb7..38a2f883b19 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -60,7 +60,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read // description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames) { Decorators = decorators ?? Array.Empty() }; + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, flattenedNames) { Decorators = decorators ?? [] }; if (id != null) { resolver.AddReference(id, property); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs index 3719b4ea976..747e6a1805e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputNullableTypeConverter.cs @@ -44,7 +44,7 @@ public static InputNullableType CreateNullableType(ref Utf8JsonReader reader, st var nullableType = new InputNullableType(valueType) { - Decorators = decorators ?? Array.Empty(), + Decorators = decorators ?? [], }; if (id != null) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs index e291bdccb09..091a871e17f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputOperationConverter.cs @@ -105,7 +105,7 @@ public override void Write(Utf8JsonWriter writer, InputOperation value, JsonSeri operation.GenerateProtocolMethod = generateProtocolMethod; operation.GenerateConvenienceMethod = generateConvenienceMethod; operation.CrossLanguageDefinitionId = crossLanguageDefinitionId ?? throw new JsonException("InputOperation must have CrossLanguageDefinitionId"); - operation.Decorators = decorators ?? Array.Empty(); + operation.Decorators = decorators ?? []; return operation; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs index f4ca48ce11d..d62ba135c98 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputParameterConverter.cs @@ -111,7 +111,7 @@ public static InputParameter CreateInputParameter(ref Utf8JsonReader reader, str arraySerializationDelimiter: arraySerializationDelimiter, headerCollectionPrefix: headerCollectionPrefix) { - Decorators = decorators ?? Array.Empty() + Decorators = decorators ?? [] }; if (id != null) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs index 74a3ba5b46e..81430aa502b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputPrimitiveTypeConverter.cs @@ -57,7 +57,7 @@ public static InputPrimitiveType CreatePrimitiveType(ref Utf8JsonReader reader, var primitiveType = new InputPrimitiveType(primitiveTypeKind, name, crossLanguageDefinitionId, encode, baseType) { - Decorators = decorators ?? Array.Empty() + Decorators = decorators ?? [] }; if (id != null) { From 1717e2d4c334828bbc9b2dbfde1abb5c4d83aafb Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Thu, 15 Aug 2024 10:32:15 +0800 Subject: [PATCH 26/26] add reference resolve for TypeSpecInputDecoratorInfoConvertor --- .../TypeSpecInputDecoratorInfoConverter.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs index 5d02035ae32..40ed2509985 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputDecoratorInfoConverter.cs @@ -19,12 +19,16 @@ public TypeSpecInputDecoratorInfoConverter(TypeSpecReferenceHandler referenceHan } public override InputDecoratorInfo? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + => reader.ReadReferenceAndResolve(_referenceHandler.CurrentResolver) ?? CreateDecoratorInfo(ref reader, null, options, _referenceHandler.CurrentResolver); + + public override void Write(Utf8JsonWriter writer, InputDecoratorInfo value, JsonSerializerOptions options) + => throw new NotSupportedException("Writing not supported"); + + private static InputDecoratorInfo? CreateDecoratorInfo(ref Utf8JsonReader reader, string? id, JsonSerializerOptions options, ReferenceResolver resolver) { - bool isFirstProperty = true; - string? id = null; + var isFirstProperty = id == null; string? name = null; IReadOnlyDictionary? arguments = null; - reader.Read(); while (reader.TokenType != JsonTokenType.EndObject) { var isKnownProperty = reader.TryReadReferenceId(ref isFirstProperty, ref id) @@ -37,17 +41,13 @@ public TypeSpecInputDecoratorInfoConverter(TypeSpecReferenceHandler referenceHan } } reader.Read(); - var decoratorInfo = new InputDecoratorInfo(name ?? throw new JsonException("InputDecoratorInfo must have name"), arguments); if (id != null) { - _referenceHandler.CurrentResolver.AddReference(id, decoratorInfo); + resolver.AddReference(id, decoratorInfo); } return decoratorInfo; } - - public override void Write(Utf8JsonWriter writer, InputDecoratorInfo value, JsonSerializerOptions options) - => throw new NotSupportedException("Writing not supported"); } }