diff --git a/powershell/llcsharp/model/model-class-serializer.ts b/powershell/llcsharp/model/model-class-serializer.ts index 7a6e7b4849..d3d653e3cf 100644 --- a/powershell/llcsharp/model/model-class-serializer.ts +++ b/powershell/llcsharp/model/model-class-serializer.ts @@ -32,7 +32,8 @@ import { ObjectImplementation } from '../schema/object'; import { Schema } from '../code-model'; import { Schema as NewSchema } from '@azure-tools/codemodel'; -import { getVirtualPropertyName } from './model-class'; +import { getVirtualPropertyName, NewGetVirtualPropertyName } from './model-class'; +import { VirtualProperty as NewVirtualProperty } from '../../utils/schema'; export class SerializationPartialClass extends Initializer { constructor(protected targetClass: Class, protected targetInterface: TypeDeclaration, protected serializationType: TypeDeclaration, protected serializationFormat: string, protected schema: Schema, protected resolver: (s: Schema, req: boolean) => EnhancedTypeDeclaration, objectInitializer?: DeepPartial) { @@ -273,16 +274,16 @@ export class NewDeserializerPartialClass extends NewSerializationPartialClass { return function* () { yield '// actually deserialize '; // skip-for-time-being - // for (const virtualProperty of values($this.allVirtualProperties)) { - // // yield `// deserialize ${virtualProperty.name} from ${$this.serializationFormat}`; - // const type = $this.resolver(virtualProperty.property.schema, virtualProperty.property.details.default.required); + for (const virtualProperty of values(>$this.allVirtualProperties)) { + // yield `// deserialize ${virtualProperty.name} from ${$this.serializationFormat}`; + const type = $this.resolver(virtualProperty.property.schema, virtualProperty.property.language.default.required); - // const cvt = type.convertObjectMethod; - // const t = `((${virtualProperty.originalContainingSchema.details.csharp.fullInternalInterfaceName})this)`; - // const tt = type ? `(${type.declaration})` : ''; + const cvt = type.convertObjectMethod; + const t = `((${virtualProperty.originalContainingSchema.language.csharp?.fullInternalInterfaceName})this)`; + const tt = type ? `(${type.declaration})` : ''; - // yield `${t}.${getVirtualPropertyName(virtualProperty)} = ${tt} ${$this.contentParameter}.GetValueForProperty("${getVirtualPropertyName(virtualProperty)}",${t}.${getVirtualPropertyName(virtualProperty)}, ${cvt});`; - // } + yield `${t}.${NewGetVirtualPropertyName(virtualProperty)} = ${tt} ${$this.contentParameter}.GetValueForProperty("${NewGetVirtualPropertyName(virtualProperty)}",${t}.${NewGetVirtualPropertyName(virtualProperty)}, ${cvt});`; + } }; } diff --git a/powershell/plugins/plugin-tweak-model.ts b/powershell/plugins/plugin-tweak-model.ts index 2638fb1c93..e58c00aec1 100644 --- a/powershell/plugins/plugin-tweak-model.ts +++ b/powershell/plugins/plugin-tweak-model.ts @@ -98,6 +98,7 @@ async function tweakModelV2(state: State): Promise { const universalId = new ObjectSchema(`${serviceName}Identity`, 'Resource Identity'); universalId.apiVersions = universalId.apiVersions || []; state.model.schemas.objects = state.model.schemas.objects || []; + (universalId.language.default).uid = 'universal-parameter-type'; state.model.schemas.objects.push(universalId); for (const group of values(model.operationGroups)) { diff --git a/powershell/plugins/ps-namer-v2.ts b/powershell/plugins/ps-namer-v2.ts index 79b536b8fd..cf926c52af 100644 --- a/powershell/plugins/ps-namer-v2.ts +++ b/powershell/plugins/ps-namer-v2.ts @@ -55,7 +55,7 @@ async function tweakModel(state: State): Promise { // make sure recursively that every details field has csharp for (const { index, instance } of linq.visitor(state.model)) { - if (index === 'details' && instance.default && !instance.csharp) { + if ((index === 'details' || index === 'language') && instance.default && !instance.csharp) { instance.csharp = linq.clone(instance.default, false, undefined, undefined, ['schema', 'origin']); } }