diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index fe6a2f9c..362bf88e 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -2110,7 +2110,7 @@ export class CmdletClass extends Class { if (operation.details.default.externalDocs) { this.add(new Attribute(ExternalDocsAttribute, { parameters: [`${new StringExpression(this.operation.details.default.externalDocs?.url ?? '')}`, - `${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`] + `${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`] })); } diff --git a/powershell/plugins/sdk-cs-namer.ts b/powershell/plugins/sdk-cs-namer.ts index a0673dfc..6e030f97 100644 --- a/powershell/plugins/sdk-cs-namer.ts +++ b/powershell/plugins/sdk-cs-namer.ts @@ -64,6 +64,8 @@ function csharpForArray(elementType: Schema, helper: Helper, nullable = true): s if (elementType.type === SchemaType.Array) { // recursively generate the csharpForArray return `System.Collections.Generic.IList<${csharpForArray((elementType).elementType, helper)}>`; + } else if (elementType.type === SchemaType.Dictionary) { + return `System.Collections.Generic.IList<${csharpForDict(elementType, helper)}>`; } const rawElementType = elementType; elementType = rawElementType; @@ -75,6 +77,22 @@ function csharpForArray(elementType: Schema, helper: Helper, nullable = true): s return `System.Collections.Generic.IList<${type ? type + postfix : (helper.IsEnum(rawElementType) && nullable ? rawElementType.language.default.name + '?' : rawElementType.language.default.name)}>`; } +function csharpForDict(dictSchema: DictionarySchema, helper: Helper): string { + const rawElementType = dictSchema.elementType; + let elementType = rawElementType; + if ((rawElementType.type === SchemaType.Choice || rawElementType.type === SchemaType.SealedChoice) && !helper.IsEnum(rawElementType)) { + elementType = (rawElementType).choiceType; + } + + let valueType = helper.GetCsharpType(elementType) ? helper.GetCsharpType(elementType) : (rawElementType.type === SchemaType.Array ? csharpForArray((rawElementType).elementType, helper) : rawElementType.language.default.name); + if (rawElementType.type === 'any') { + valueType = 'object'; + } + if (((helper.GetCsharpType(elementType) && valueType !== 'string') || helper.IsEnum(rawElementType)) && dictSchema.nullableItems != false) { + valueType += '?'; + } + return `System.Collections.Generic.IDictionary`; +} function setSchemaNames(schemaGroups: Dictionary>, azure: boolean, serviceNamespace: string, helper: Helper) { const baseNamespace = new Set(); @@ -221,7 +239,7 @@ function setSchemaNames(schemaGroups: Dictionary>, azure: boolean, apiversion: thisApiversion, apiname: apiName, name: schemaName, - fullname: `System.Collections.Generic.IDictionary`, + fullname: csharpForDict(schema, helper), }; } }