diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs index aa2dfc5ca..f472c75c7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs @@ -26,7 +26,8 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers /// internal class MrwSerializationTypeDefinition : TypeProvider { - private const string PrivateAdditionalPropertiesPropertyName = "_serializedAdditionalRawData"; + private const string AdditionalBinaryDataPropertiesFieldName = "_additionalBinaryDataProperties"; + private const string AdditionBinaryDataPropertiesPropertyName = "AdditionalBinaryDataProperties"; private const string JsonModelWriteCoreMethodName = "JsonModelWriteCore"; private const string JsonModelCreateCoreMethodName = "JsonModelCreateCore"; private const string PersistableModelWriteCoreMethodName = "PersistableModelWriteCore"; @@ -51,6 +52,7 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers private readonly ModelProvider _model; private readonly InputModelType _inputModel; private readonly FieldProvider? _rawDataField; + private readonly PropertyProvider? _additionalBinaryDataProperty; private readonly bool _isStruct; private ConstructorProvider? _serializationConstructor; // Flag to determine if the model should override the serialization methods @@ -67,7 +69,10 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers _jsonModelObjectInterface = _isStruct ? (CSharpType)typeof(IJsonModel) : null; _persistableModelTInterface = new CSharpType(typeof(IPersistableModel<>), interfaceType.Type); _persistableModelObjectInterface = _isStruct ? (CSharpType)typeof(IPersistableModel) : null; - _rawDataField = _model.Fields.FirstOrDefault(f => f.Name == PrivateAdditionalPropertiesPropertyName); + _rawDataField = _model.Fields.FirstOrDefault(f => f.Name == AdditionalBinaryDataPropertiesFieldName); + _additionalBinaryDataProperty = _model.Properties.FirstOrDefault( + p => p.Name == AdditionBinaryDataPropertiesPropertyName + || p.Name == "AdditionalProperties" && p.Type.IsDictionary && p.Type.ElementType.Equals(typeof(BinaryData))); _shouldOverrideMethods = _model.Type.BaseType != null && _model.Type.BaseType is { IsFrameworkType: false }; _utf8JsonWriterSnippet = _utf8JsonWriterParameter.As(); _mrwOptionsParameterSnippet = _serializationOptionsParameter.As(); @@ -567,10 +572,10 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers Debug.Assert(parameter.Field != null); var field = parameter.Field; var fieldRef = field.AsVariableExpression; - if (field.Name == PrivateAdditionalPropertiesPropertyName) + if (field.Name == AdditionalBinaryDataPropertiesFieldName) { // the raw data is kind of different because we assign it with an instance, not like others properties/fields - // IDictionary serializedAdditionalRawData = new Dictionary(); + // IDictionary additionalBinaryDataProperties = new Dictionary(); propertyDeclarationStatements.Add(Declare(fieldRef, new DictionaryExpression(field.Type, New.Instance(field.Type.PropertyInitializationType)))); } else @@ -729,7 +734,16 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers } // deserialize the raw data properties - if (_rawDataField != null) + if (_additionalBinaryDataProperty != null) + { + var elementType = _additionalBinaryDataProperty.Type.Arguments[1].FrameworkType; + var rawDataDeserializationValue = GetValueTypeDeserializationExpression(elementType, jsonProperty.Value(), SerializationFormat.Default); + propertyDeserializationStatements.Add(new IfStatement(_isNotEqualToWireConditionSnippet) + { + _additionalBinaryDataProperty.AsVariableExpression.AsDictionary(_additionalBinaryDataProperty.Type).Add(jsonProperty.Name(), rawDataDeserializationValue) + }); + } + else if (_rawDataField != null) { var elementType = _rawDataField.Type.Arguments[1].FrameworkType; var rawDataDeserializationValue = GetValueTypeDeserializationExpression(elementType, jsonProperty.Value(), SerializationFormat.Default); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/CamelCaseSerializedName.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/CamelCaseSerializedName.cs index 8318708d3..dca839338 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/CamelCaseSerializedName.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/CamelCaseSerializedName.cs @@ -22,9 +22,9 @@ namespace sample.namespace.Models } writer.WritePropertyName("camelCase"u8); writer.WriteStringValue(CamelCase); - if (((options.Format != "W") && (_serializedAdditionalRawData != null))) + if (((options.Format != "W") && (_additionalBinaryDataProperties != null))) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/KebabCaseSerializedName.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/KebabCaseSerializedName.cs index d7ea9b91d..eeddba905 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/KebabCaseSerializedName.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/KebabCaseSerializedName.cs @@ -22,9 +22,9 @@ namespace sample.namespace.Models } writer.WritePropertyName("kebab-case"u8); writer.WriteStringValue(KebabCase); - if (((options.Format != "W") && (_serializedAdditionalRawData != null))) + if (((options.Format != "W") && (_additionalBinaryDataProperties != null))) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/PascalCaseSerializedName.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/PascalCaseSerializedName.cs index 263de30c9..383d21cb9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/PascalCaseSerializedName.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/PascalCaseSerializedName.cs @@ -22,9 +22,9 @@ namespace sample.namespace.Models } writer.WritePropertyName("PascalCase"u8); writer.WriteStringValue(PascalCase); - if (((options.Format != "W") && (_serializedAdditionalRawData != null))) + if (((options.Format != "W") && (_additionalBinaryDataProperties != null))) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/SnakeCaseSerializedName.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/SnakeCaseSerializedName.cs index ef5d987e2..6c45d58ad 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/SnakeCaseSerializedName.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/JsonModelCoreTests/SnakeCaseSerializedName.cs @@ -22,9 +22,9 @@ namespace sample.namespace.Models } writer.WritePropertyName("snake_case"u8); writer.WriteStringValue(SnakeCase); - if (((options.Format != "W") && (_serializedAdditionalRawData != null))) + if (((options.Format != "W") && (_additionalBinaryDataProperties != null))) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs index 4a4d20aa1..0dfe698ef 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs @@ -17,7 +17,7 @@ namespace Microsoft.Generator.CSharp.Providers internal class ModelFactoryProvider : TypeProvider { private const string ModelFactorySuffix = "ModelFactory"; - private const string AdditionalRawDataParameterName = "serializedAdditionalRawData"; + private const string AdditionalBinaryDataParameterName = "additionalBinaryDataProperties"; private readonly IEnumerable _models; @@ -84,7 +84,7 @@ namespace Microsoft.Generator.CSharp.Providers MethodSignatureModifiers.Static | MethodSignatureModifiers.Public, modelProvider.Type, $"A new {modelProvider.Type:C} instance for mocking.", - GetParameters(modelCtor)); + GetParameters(modelCtor, modelProvider.SupportsBinaryDataAdditionalProperties)); var docs = new XmlDocProvider(); docs.Summary = modelProvider.XmlDocs?.Summary; @@ -98,7 +98,7 @@ namespace Microsoft.Generator.CSharp.Providers [ .. GetCollectionInitialization(signature), MethodBodyStatement.EmptyLine, - Return(New.Instance(typeToInstantiate.Type, [.. GetCtorArgs(signature, modelCtor.Signature)])) + Return(New.Instance(typeToInstantiate.Type, [.. GetCtorArgs(signature, modelCtor.Signature, modelProvider.SupportsBinaryDataAdditionalProperties)])) ]); methods.Add(new MethodProvider(signature, statements, this, docs)); @@ -108,7 +108,8 @@ namespace Microsoft.Generator.CSharp.Providers private static IReadOnlyList GetCtorArgs( MethodSignature signature, - ConstructorSignature modelCtorFullSignature) + ConstructorSignature modelCtorFullSignature, + bool supportsBinaryDataAdditionalProps) { var expressions = new List(signature.Parameters.Count); for (int i = 0; i < signature.Parameters.Count; i++) @@ -129,8 +130,8 @@ namespace Microsoft.Generator.CSharp.Providers } } - var modelContainsAdditionalRawData = modelCtorFullSignature.Parameters.Any(p => p.Name.Equals(AdditionalRawDataParameterName)); - if (modelContainsAdditionalRawData) + var modelContainsAdditionalRawData = modelCtorFullSignature.Parameters.Any(p => p.Name.Equals(AdditionalBinaryDataParameterName)); + if (modelContainsAdditionalRawData && !supportsBinaryDataAdditionalProps) { expressions.Add(Null); } @@ -151,13 +152,15 @@ namespace Microsoft.Generator.CSharp.Providers return [.. statements]; } - private static IReadOnlyList GetParameters(ConstructorProvider modelFullConstructor) + private static IReadOnlyList GetParameters( + ConstructorProvider modelFullConstructor, + bool supportsBinaryDataAdditionalProps) { var modelCtorParams = modelFullConstructor.Signature.Parameters; var parameters = new List(modelCtorParams.Count); foreach (var param in modelCtorParams) { - if (param.Name.Equals(AdditionalRawDataParameterName)) + if (param.Name.Equals(AdditionalBinaryDataParameterName) && !supportsBinaryDataAdditionalProps) continue; parameters.Add(GetModelFactoryParam(param)); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs index b8f6d4b9f..75b85e6bc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs @@ -17,18 +17,19 @@ namespace Microsoft.Generator.CSharp.Providers { public sealed class ModelProvider : TypeProvider { - private const string PrivateAdditionalPropertiesPropertyDescription = "Keeps track of any properties unknown to the library."; - private const string PrivateAdditionalPropertiesPropertyName = "_serializedAdditionalRawData"; - private const string AdditionalPropertiesPropertyName = "AdditionalProperties"; + private const string AdditionalBinaryDataPropsFieldDescription = "Keeps track of any properties unknown to the library."; + private const string AdditionalBinaryDataPropsFieldName = "_additionalBinaryDataProperties"; + private const string DefaultAdditionalPropertiesPropertyName = "AdditionalProperties"; private readonly InputModelType _inputModel; protected override FormattableString Description { get; } - private readonly CSharpType _privateAdditionalRawDataPropertyType = typeof(IDictionary); + private readonly CSharpType _additionalBinaryDataPropsFieldType = typeof(IDictionary); private readonly Type _additionalPropsUnknownType = typeof(BinaryData); private readonly Lazy? _baseTypeProvider; private FieldProvider? _rawDataField; - private PropertyProvider? _additionalProperties; + private List? _additionalPropertyFields; + private List? _additionalPropertyProperties; private ModelProvider? _baseModelProvider; private ConstructorProvider? _fullConstructor; @@ -70,8 +71,9 @@ namespace Microsoft.Generator.CSharp.Providers private ModelProvider? BaseModelProvider => _baseModelProvider ??= (_baseTypeProvider?.Value is ModelProvider baseModelProvider ? baseModelProvider : null); private FieldProvider? RawDataField => _rawDataField ??= BuildRawDataField(); - private PropertyProvider? AdditionalPropertiesProperty => _additionalProperties ??= BuildAdditionalProperties(); - + private List AdditionalPropertyFields => _additionalPropertyFields ??= BuildAdditionalPropertyFields(); + private List AdditionalPropertyProperties => _additionalPropertyProperties ??= BuildAdditionalPropertyProperties(); + internal bool SupportsBinaryDataAdditionalProperties => AdditionalPropertyProperties.Any(p => p.Type.ElementType.Equals(_additionalPropsUnknownType)); public ConstructorProvider FullConstructor => _fullConstructor ??= BuildFullConstructor(); protected override string GetNamespace() => CodeModelPlugin.Instance.Configuration.ModelNamespace; @@ -150,6 +152,13 @@ namespace Microsoft.Generator.CSharp.Providers { fields.Add(RawDataField); } + + // add fields for additional properties + if (AdditionalPropertyFields.Count > 0) + { + fields.AddRange(AdditionalPropertyFields); + } + foreach (var property in _inputModel.Properties) { if (property.IsDiscriminator) @@ -171,6 +180,112 @@ namespace Microsoft.Generator.CSharp.Providers return [.. fields]; } + private List BuildAdditionalPropertyFields() + { + var fields = new List(); + + if (_inputModel.AdditionalProperties != null) + { + var valueType = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(_inputModel.AdditionalProperties); + if (valueType != null) + { + if (valueType.IsUnion) + { + foreach (var unionType in valueType.UnionItemTypes) + { + AddFieldForAdditionalProperties(unionType, fields); + } + } + else + { + AddFieldForAdditionalProperties(valueType, fields); + } + } + } + + return fields; + } + + private void AddFieldForAdditionalProperties(CSharpType valueType, List fields) + { + var originalType = new CSharpType(typeof(IDictionary<,>), typeof(string), valueType); + var additionalPropsType = ReplaceUnverifiableType(originalType); + + if (!additionalPropsType.Equals(_additionalBinaryDataPropsFieldType)) + { + fields.Add(new FieldProvider( + FieldModifiers.Private, + additionalPropsType, + BuildAdditionalTypePropertiesFieldName(additionalPropsType.ElementType), + this)); + } + } + + private List BuildAdditionalPropertyProperties() + { + var additionalPropertiesFieldCount = AdditionalPropertyFields.Count; + var properties = new List(additionalPropertiesFieldCount + 1); + bool containsAdditionalTypeProperties = false; + + for (int i = 0; i < additionalPropertiesFieldCount; i++) + { + var field = AdditionalPropertyFields[i]; + var propertyType = !_inputModel.Usage.HasFlag(InputModelTypeUsage.Input) ? field.Type.OutputType : field.Type; + var assignment = propertyType.IsReadOnlyDictionary + ? new ExpressionPropertyBody(New.ReadOnlyDictionary(propertyType.Arguments[0], propertyType.ElementType, field)) + : new ExpressionPropertyBody(field); + + properties.Add(new( + null, + MethodSignatureModifiers.Public, + propertyType, + i == 0 ? DefaultAdditionalPropertiesPropertyName : field.Name.ToCleanName(), + assignment, + this)); + containsAdditionalTypeProperties = true; + } + + if (RawDataField == null || _inputModel.AdditionalProperties == null) + { + return properties; + } + + var apValueType = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(_inputModel.AdditionalProperties); + if (apValueType == null) + { + return properties; + } + + // add public property for raw binary data if the model supports additional binary data properties + var originalType = new CSharpType(typeof(IDictionary<,>), typeof(string), apValueType); + var additionalPropsType = ReplaceUnverifiableType(originalType); + var shouldAddPropForUnionType = additionalPropsType.ElementType.IsUnion + && additionalPropsType.ElementType.UnionItemTypes.Any(t => !t.IsFrameworkType); + + if (shouldAddPropForUnionType || (!apValueType.IsUnion && additionalPropsType.Equals(_additionalBinaryDataPropsFieldType))) + { + var name = !containsAdditionalTypeProperties + ? DefaultAdditionalPropertiesPropertyName + : RawDataField.Name.ToCleanName(); + var type = !_inputModel.Usage.HasFlag(InputModelTypeUsage.Input) + ? additionalPropsType.OutputType + : additionalPropsType; + var assignment = type.IsReadOnlyDictionary + ? new ExpressionPropertyBody(New.ReadOnlyDictionary(type.Arguments[0], type.ElementType, RawDataField)) + : new ExpressionPropertyBody(RawDataField); + + properties.Add(new( + null, + MethodSignatureModifiers.Public, + type, + name, + assignment, + this)); + } + + return properties; + } + private Dictionary>? _inputDerivedProperties; private Dictionary> InputDerivedProperties => _inputDerivedProperties ??= BuildDerivedProperties(); @@ -254,9 +369,9 @@ namespace Microsoft.Generator.CSharp.Providers properties.Add(outputProperty); } - if (AdditionalPropertiesProperty != null) + if (AdditionalPropertyProperties.Count > 0) { - properties.Add(AdditionalPropertiesProperty); + properties.AddRange(AdditionalPropertyProperties); } return [.. properties]; @@ -368,9 +483,13 @@ namespace Microsoft.Generator.CSharp.Providers if (!isPrimaryConstructor) { - if (AdditionalPropertiesProperty != null) - constructorParameters.Add(AdditionalPropertiesProperty.AsParameter); - if (RawDataField != null) + foreach (var property in AdditionalPropertyProperties) + { + constructorParameters.Add(property.AsParameter); + } + + // only add the raw data field if it has not already been added as a parameter for BinaryData additional properties + if (RawDataField != null && !SupportsBinaryDataAdditionalProperties) constructorParameters.Add(RawDataField.AsParameter); } @@ -522,18 +641,30 @@ namespace Microsoft.Generator.CSharp.Providers } } - if (AdditionalPropertiesProperty != null) + // handle additional properties + foreach (var property in AdditionalPropertyProperties) { - var assignment = isPrimaryConstructor - ? AdditionalPropertiesProperty.Assign(New.Instance(AdditionalPropertiesProperty.Type.PropertyInitializationType)) - : AdditionalPropertiesProperty.Assign(AdditionalPropertiesProperty.AsParameter); + // find the corresponding backing field for the property + var backingField = AdditionalPropertyFields.FirstOrDefault(f => f.Type.ElementType.Equals(property.Type.ElementType)) + ?? (RawDataField != null && property.Type.ElementType.Equals(RawDataField.Type.ElementType) ? RawDataField : null); - methodBodyStatements.Add(assignment.Terminate()); + if (backingField != null) + { + var assignment = isPrimaryConstructor + ? backingField.Assign(New.Instance(backingField.Type.PropertyInitializationType)) + : backingField.Assign(property.AsParameter); + + methodBodyStatements.Add(assignment.Terminate()); + } } - if (!isPrimaryConstructor && RawDataField != null) + if (RawDataField != null) { - methodBodyStatements.Add(RawDataField.Assign(RawDataField.AsParameter).Terminate()); + // initialize the raw data field in the serialization constructor if the model does not explicitly support AP of binary data. + if (!isPrimaryConstructor && !SupportsBinaryDataAdditionalProperties) + { + methodBodyStatements.Add(RawDataField.Assign(RawDataField.AsParameter).Terminate()); + } } return methodBodyStatements; @@ -564,17 +695,6 @@ namespace Microsoft.Generator.CSharp.Providers return null; } - // validate if the additional properties property exists & if its' value type is also BinaryData - // if so, we do not have to have a raw data field since the additional properties property will be used for serialization - // of raw data - if ((AdditionalPropertiesProperty != null - && AdditionalPropertiesProperty.Type.ElementType.Equals(_additionalPropsUnknownType, ignoreNullable: true)) || - (BaseModelProvider?.AdditionalPropertiesProperty != null - && BaseModelProvider.AdditionalPropertiesProperty.Type.ElementType.Equals(_additionalPropsUnknownType, ignoreNullable: true))) - { - return null; - } - var modifiers = FieldModifiers.Private; if (!DeclarationModifiers.HasFlag(TypeSignatureModifiers.Sealed)) { @@ -583,40 +703,14 @@ namespace Microsoft.Generator.CSharp.Providers var rawDataField = new FieldProvider( modifiers: modifiers, - type: _privateAdditionalRawDataPropertyType, - description: FormattableStringHelpers.FromString(PrivateAdditionalPropertiesPropertyDescription), - name: PrivateAdditionalPropertiesPropertyName, + type: _additionalBinaryDataPropsFieldType, + description: FormattableStringHelpers.FromString(AdditionalBinaryDataPropsFieldDescription), + name: AdditionalBinaryDataPropsFieldName, enclosingType: this); return rawDataField; } - private PropertyProvider? BuildAdditionalProperties() - { - var additionalProperties = _inputModel.AdditionalProperties; - if (additionalProperties is null) - { - return null; - } - - var valueType = CodeModelPlugin.Instance.TypeFactory.CreateCSharpType(additionalProperties); - if (valueType is null) - throw new InvalidOperationException($"Failed to create CSharpType for additional properties of model {_inputModel.Name}"); - - var originalType = new CSharpType(typeof(IDictionary<,>), typeof(string), valueType); - var additionalPropsType = !_inputModel.Usage.HasFlag(InputModelTypeUsage.Input) - ? ReplaceUnverifiableType(originalType).OutputType - : ReplaceUnverifiableType(originalType); - - return new PropertyProvider( - null, - MethodSignatureModifiers.Public, - additionalPropsType, - name: AdditionalPropertiesPropertyName, - new AutoPropertyBody(false), - enclosingType: this); - } - /// /// Replaces unverifiable types, types that do not have value kind checks during deserialization of additional properties, /// with the corresponding verifiable types. By default, BinaryData is used as the value type for unknown additional properties. @@ -636,6 +730,19 @@ namespace Microsoft.Generator.CSharp.Providers }; } + private static string BuildAdditionalTypePropertiesFieldName(CSharpType additionalPropertiesValueType) + { + var name = additionalPropertiesValueType.Name; + + while (additionalPropertiesValueType.IsCollection) + { + additionalPropertiesValueType = additionalPropertiesValueType.ElementType; + name += additionalPropertiesValueType.Name; + } + + return $"_additional{name.ToCleanName()}Properties"; + } + /// /// The set of known verifiable additional property value types that have value kind checks during deserialization. /// diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.New.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.New.cs index 5b348d278..3b2960bba 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.New.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.New.cs @@ -52,6 +52,8 @@ namespace Microsoft.Generator.CSharp.Snippets public static IndexableExpression Array(CSharpType? elementType, bool isInline, bool isStackAlloc, params ValueExpression[] items) => new(new NewArrayExpression(elementType, new ArrayInitializerExpression(items, isInline), IsStackAlloc: isStackAlloc)); public static IndexableExpression Array(CSharpType? elementType, ValueExpression size) => new(new NewArrayExpression(elementType, Size: size)); + public static DictionaryExpression ReadOnlyDictionary(CSharpType keyType, CSharpType valueType, params ValueExpression[] items) + => new(new NewInstanceExpression(new CSharpType(typeof(System.Collections.ObjectModel.ReadOnlyDictionary<,>), keyType, valueType), items)); public static DictionaryExpression Dictionary(CSharpType keyType, CSharpType valueType) => new(new NewInstanceExpression(new CSharpType(typeof(Dictionary<,>), keyType, valueType), [])); public static DictionaryExpression Dictionary(CSharpType keyType, CSharpType valueType, IReadOnlyDictionary values) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoryProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoryProviderTests.cs index 77188a8a1..d27a68693 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoryProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoryProviderTests.cs @@ -64,7 +64,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelFactories Assert.IsNotNull(model, "Null ModelProvider found"); var method = modelFactory.Methods.FirstOrDefault(m => m.Signature.Name == model!.Name); Assert.IsNotNull(method); - foreach (var property in model!.Properties.Where(p => p.Type.IsDictionary)) + foreach (var property in model!.Properties.Where(p => p.Type.IsDictionary && !p.Name.StartsWith("Additional"))) { var parameter = method!.Signature.Parameters.FirstOrDefault(p => p.Name == property.Name.ToVariableName()); Assert.IsNotNull(parameter); @@ -97,6 +97,30 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelFactories } } + [Test] + public void AdditionalPropertiesParamShape() + { + var modelFactory = ModelFactoryProvider.FromInputLibrary(); + var models = ModelList.Select(CodeModelPlugin.Instance.TypeFactory.CreateModel); + foreach (var model in models) + { + if (!model!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Public)) + continue; //skip internal models + + Assert.IsNotNull(model, "Null ModelProvider found"); + var method = modelFactory.Methods.FirstOrDefault(m => m.Signature.Name == model!.Name); + Assert.IsNotNull(method); + foreach (var _ in model!.Properties.Where(p => p.Type.IsDictionary && p.Name.StartsWith("Additional"))) + { + var parameter = method!.Signature.Parameters.FirstOrDefault(p => p.Name == "additionalProperties"); + Assert.IsNotNull(parameter); + Assert.IsTrue(parameter!.Type.IsFrameworkType); + Assert.AreEqual(typeof(IDictionary<,>), parameter!.Type.FrameworkType); + Assert.IsTrue(parameter.Type.ContainsBinaryData); + } + } + } + [Test] public void ModelFactoryName() { @@ -106,6 +130,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelFactories private static InputModelType[] GetTestModels() { + InputType additionalPropertiesUnknown = InputPrimitiveType.Any; InputModelProperty[] properties = [ InputFactory.Property("StringProp", InputPrimitiveType.String), @@ -127,6 +152,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelFactories InputFactory.Model("PublicModel2", properties: properties), derivedModel, InputFactory.Model("BaseModel", properties: properties, derivedModels: [derivedModel]), + InputFactory.Model("ModelWithUnknownAdditionalProperties", properties: properties, additionalProperties: additionalPropertiesUnknown), ]; } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/DiscriminatorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/DiscriminatorTests.cs index 606b19c10..6050982a7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/DiscriminatorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/DiscriminatorTests.cs @@ -129,7 +129,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelProviders Assert.AreEqual(2, catModel!.Constructors.Count); var serializationCtor = catModel.Constructors.FirstOrDefault(c => c.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Internal)); Assert.IsNotNull(serializationCtor); - Assert.AreEqual("serializedAdditionalRawData", serializationCtor!.Signature.Parameters.Last().Name); + Assert.AreEqual("additionalBinaryDataProperties", serializationCtor!.Signature.Parameters.Last().Name); } [Test] diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ModelProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ModelProviderTests.cs index cb4773a50..3e97d1a71 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ModelProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ModelProviderTests.cs @@ -256,7 +256,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelProviders Assert.AreEqual(new CSharpType(typeof(string), true), secondaryCtorParameters[1].Type); Assert.AreEqual("additionalProperties", secondaryCtorParameters[2].Name); Assert.AreEqual(new CSharpType(typeof(IDictionary)), secondaryCtorParameters[2].Type); - Assert.AreEqual("serializedAdditionalRawData", secondaryCtorParameters[3].Name); + Assert.AreEqual("additionalBinaryDataProperties", secondaryCtorParameters[3].Name); Assert.AreEqual(new CSharpType(typeof(IDictionary)), secondaryCtorParameters[3].Type); // validate derived secondary constructor Assert.AreEqual(6, derivedSecondaryCtorParams.Count); // all base props + 2 properties + 1 additionalRawData + additional props @@ -270,7 +270,7 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelProviders Assert.AreEqual(new CSharpType(typeof(string), true), derivedSecondaryCtorParams[3].Type); Assert.AreEqual("additionalProperties", derivedSecondaryCtorParams[4].Name); Assert.AreEqual(new CSharpType(typeof(IDictionary)), derivedSecondaryCtorParams[4].Type); - Assert.AreEqual("serializedAdditionalRawData", derivedSecondaryCtorParams[5].Name); + Assert.AreEqual("additionalBinaryDataProperties", derivedSecondaryCtorParams[5].Name); Assert.AreEqual(new CSharpType(typeof(IDictionary)), derivedSecondaryCtorParams[5].Type); } @@ -296,14 +296,14 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelProviders Assert.AreEqual(new CSharpType(typeof(IDictionary)), additionalPropertiesParam?.Type); var rawDataParam = constructorSignature?.Parameters[1]; Assert.IsNotNull(rawDataParam); - Assert.AreEqual("serializedAdditionalRawData", rawDataParam?.Name); + Assert.AreEqual("additionalBinaryDataProperties", rawDataParam?.Name); } else { Assert.AreEqual(1, constructorSignature?.Parameters.Count); var param = constructorSignature?.Parameters[0]; Assert.IsNotNull(param); - Assert.AreEqual("serializedAdditionalRawData", param?.Name); + Assert.AreEqual("additionalBinaryDataProperties", param?.Name); } } @@ -350,58 +350,137 @@ namespace Microsoft.Generator.CSharp.Tests.Providers.ModelProviders [TestCase(true)] [TestCase(false)] - public void TestBuildFields(bool containsUnknownAdditionalProp) + public void TestBuildFields(bool containsMixedAdditionalProperties) { - InputType? additionalProperties = containsUnknownAdditionalProp ? InputPrimitiveType.Any : null; + InputType? additionalProperties = containsMixedAdditionalProperties + ? InputFactory.Union([InputPrimitiveType.Float64, InputPrimitiveType.Int64, InputPrimitiveType.String]) + : null; var inputModel = InputFactory.Model("TestModel", properties: [], additionalProperties: additionalProperties); var modelTypeProvider = new ModelProvider(inputModel); var fields = modelTypeProvider.Fields; - // Assert Assert.IsNotNull(fields); - if (containsUnknownAdditionalProp) + + if (containsMixedAdditionalProperties) { - Assert.AreEqual(0, fields.Count); + Assert.AreEqual(4, fields.Count); + Assert.AreEqual("_additionalBinaryDataProperties", fields[0].Name); + Assert.AreEqual(new CSharpType(typeof(IDictionary)), fields[0].Type); + Assert.AreEqual("_additionalDoubleProperties", fields[1].Name); + Assert.AreEqual(new CSharpType(typeof(IDictionary)), fields[1].Type); + Assert.AreEqual("_additionalInt64Properties", fields[2].Name); + Assert.AreEqual(new CSharpType(typeof(IDictionary)), fields[2].Type); + Assert.AreEqual("_additionalStringProperties", fields[3].Name); + Assert.AreEqual(new CSharpType(typeof(IDictionary)), fields[3].Type); } else { Assert.AreEqual(1, fields.Count); - Assert.AreEqual("_serializedAdditionalRawData", fields[0].Name); - var type = fields[0].Type; - Assert.IsTrue(type.IsCollection); + Assert.AreEqual("_additionalBinaryDataProperties", fields[0].Name); + Assert.AreEqual(new CSharpType(typeof(IDictionary)), fields[0].Type); } } [TestCaseSource(nameof(BuildAdditionalPropertiesTestCases))] - public void TestBuildAdditionalProperties(InputType additionalProperties, bool isUnverifiableType) + public void TestBuildAdditionalProperties( + InputModelType inputModel, + bool isUnverifiableType, + int expectedPropertyCount) { - var inputModel = InputFactory.Model("TestModel", properties: [], additionalProperties: additionalProperties); var modelTypeProvider = new ModelProvider(inputModel); - var additionalPropertiesProp = modelTypeProvider.Properties.FirstOrDefault(f => f.Name == "AdditionalProperties"); - Assert.IsNotNull(additionalPropertiesProp); + var additionalPropertiesProps = modelTypeProvider.Properties.Where(f => f.Name.StartsWith("Additional")).ToList(); + Assert.AreEqual(expectedPropertyCount, additionalPropertiesProps.Count); - var additionalPropertiesType = additionalPropertiesProp!.Type; - Assert.IsTrue(additionalPropertiesType.IsDictionary); - - if (isUnverifiableType) + foreach (var additionalPropertiesProp in additionalPropertiesProps) { - Assert.AreEqual(new CSharpType(typeof(IDictionary)), additionalPropertiesType); + var additionalPropertiesType = additionalPropertiesProp!.Type; + Assert.IsTrue(additionalPropertiesType.IsDictionary); + + if (isUnverifiableType) + { + Assert.AreEqual(new CSharpType(typeof(IDictionary)), additionalPropertiesType); + } + if (!inputModel.Usage.HasFlag(InputModelTypeUsage.Input)) + { + Assert.IsTrue(additionalPropertiesType.IsReadOnlyDictionary); + // validate the assignment + var body = additionalPropertiesProp.Body as ExpressionPropertyBody; + Assert.NotNull(body); + Assert.IsTrue(body!.Getter.ToDisplayString().StartsWith( + "new global::System.Collections.ObjectModel.ReadOnlyDictionary f.Name.StartsWith("Additional")).ToList(); + + Assert.AreEqual(2, additionalProperties1.Count); + // validate modifiers + Assert.IsTrue(additionalProperties1[0]!.Modifiers.HasFlag(MethodSignatureModifiers.Public)); + Assert.IsTrue(additionalProperties1[1]!.Modifiers.HasFlag(MethodSignatureModifiers.Public)); + // validate names + Assert.AreEqual("AdditionalProperties", additionalProperties1[0].Name); + Assert.AreEqual("AdditionalInt32Properties", additionalProperties1[1].Name); + // validate getters + var stringAdditionalPropertyGetter = additionalProperties1[0]!.Body as ExpressionPropertyBody; + Assert.NotNull(stringAdditionalPropertyGetter); + Assert.IsTrue(stringAdditionalPropertyGetter!.Getter.ToDisplayString().Equals("_additionalStringProperties")); + var int32AdditionalPropertyGetter = additionalProperties1[1]!.Body as ExpressionPropertyBody; + Assert.NotNull(int32AdditionalPropertyGetter); + Assert.IsTrue(int32AdditionalPropertyGetter!.Getter.ToDisplayString().Equals("_additionalInt32Properties")); + + // model with single additional property + var inputModelWithSingleAp = InputFactory.Model( + "TestModel", + properties: [], + additionalProperties: InputPrimitiveType.String); + var modelWithSingleAp = new ModelProvider(inputModelWithSingleAp); + var additionalProperties2 = modelWithSingleAp.Properties.Where(f => f.Name.StartsWith("Additional")).ToList(); + + Assert.AreEqual(1, additionalProperties2.Count); + // validate modifiers + Assert.IsTrue(additionalProperties2[0]!.Modifiers.HasFlag(MethodSignatureModifiers.Public)); + // validate names + Assert.AreEqual("AdditionalProperties", additionalProperties2[0].Name); + // validate getters + var singleAdditionalPropertyGetter = additionalProperties2[0]!.Body as ExpressionPropertyBody; + Assert.NotNull(singleAdditionalPropertyGetter); + Assert.IsTrue(singleAdditionalPropertyGetter!.Getter.ToDisplayString().Equals("_additionalStringProperties")); + + // model with no additional properties + var inputModelWithNoAp = InputFactory.Model("TestModel", properties: []); + var modelWithNoAp = new ModelProvider(inputModelWithNoAp); + var additionalProperties3 = modelWithNoAp.Properties.Where(f => f.Name.StartsWith("Additional")).ToList(); + Assert.AreEqual(0, additionalProperties3.Count); + + } + public static IEnumerable BuildAdditionalPropertiesTestCases { get { // verifiable type - yield return new TestCaseData(InputPrimitiveType.String, false); - yield return new TestCaseData(InputFactory.Array(InputPrimitiveType.String), false); - yield return new TestCaseData(InputFactory.Dictionary(InputPrimitiveType.String), false); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputPrimitiveType.String), false, 1); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputFactory.Array(InputPrimitiveType.String)), false, 1); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputFactory.Dictionary(InputPrimitiveType.String)), false, 1); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputFactory.Union([InputPrimitiveType.String, InputPrimitiveType.Int32])), false, 2); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputFactory.Union([InputPrimitiveType.String, InputPrimitiveType.Int32, InputFactory.Model("foo")])), false, 3); + // output model + yield return new TestCaseData(InputFactory.Model("TestModel", usage: InputModelTypeUsage.Output, properties: [], additionalProperties: InputPrimitiveType.String), false, 1); // non-verifiable type - yield return new TestCaseData(InputPrimitiveType.Any, true); - yield return new TestCaseData(InputFactory.Model("foo"), true); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputPrimitiveType.Any), true, 1); + yield return new TestCaseData(InputFactory.Model("TestModel", properties: [], additionalProperties: InputFactory.Model("foo")), true, 1); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModel.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModel.cs index e533c2af3..cbff70a84 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModel.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModel.cs @@ -12,7 +12,7 @@ namespace Sample.Models public partial class TestModel { /// Keeps track of any properties unknown to the library. - private protected global::System.Collections.Generic.IDictionary _serializedAdditionalRawData; + private protected global::System.Collections.Generic.IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Description for requiredString. @@ -26,11 +26,11 @@ namespace Sample.Models RequiredInt = requiredInt; } - internal TestModel(string requiredString, int requiredInt, global::System.Collections.Generic.IDictionary serializedAdditionalRawData) + internal TestModel(string requiredString, int requiredInt, global::System.Collections.Generic.IDictionary additionalBinaryDataProperties) { RequiredString = requiredString; RequiredInt = requiredInt; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Description for requiredString. diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModelAsStruct.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModelAsStruct.cs index e46950480..def951028 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModelAsStruct.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Writers/TestData/TypeProviderWriterTests/TypeProviderWriter_WriteModelAsStruct.cs @@ -12,7 +12,7 @@ namespace Sample.Models public readonly partial struct TestModel { /// Keeps track of any properties unknown to the library. - private protected global::System.Collections.Generic.IDictionary _serializedAdditionalRawData; + private protected global::System.Collections.Generic.IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Description for requiredString. @@ -26,11 +26,11 @@ namespace Sample.Models RequiredInt = requiredInt; } - internal TestModel(string requiredString, int requiredInt, global::System.Collections.Generic.IDictionary serializedAdditionalRawData) + internal TestModel(string requiredString, int requiredInt, global::System.Collections.Generic.IDictionary additionalBinaryDataProperties) { RequiredString = requiredString; RequiredInt = requiredInt; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Description for requiredString. diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs index 00286ec75..8839268bc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs @@ -186,6 +186,11 @@ namespace Microsoft.Generator.CSharp.Tests.Common return new InputDictionaryType("dictionary", keyType ?? InputPrimitiveType.String, valueType); } + public static InputType Union(IList types) + { + return new InputUnionType("union", [.. types]); + } + public static InputOperation Operation( string name, string access = "public", diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/ModelTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/ModelTests.cs index c71e168f0..0d1b48e17 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/ModelTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/ModelTests.cs @@ -198,7 +198,7 @@ namespace Microsoft.Generator.CSharp.Tests.Common { modelType = modelType.BaseType!; } - var propertyInfo = modelType.GetField("_serializedAdditionalRawData", BindingFlags.Instance | BindingFlags.NonPublic); + var propertyInfo = modelType.GetField("_additionalBinaryDataProperties", BindingFlags.Instance | BindingFlags.NonPublic); return propertyInfo?.GetValue(model) as IDictionary ?? throw new InvalidOperationException($"unable to get raw data from {model.GetType().Name}"); } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Cobra.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Cobra.cs index 5ad975478..208d53b8a 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Cobra.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Cobra.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { public Cobra(int length) : base(SnakeKind.Cobra, length) => throw null; - internal Cobra(int length, IDictionary serializedAdditionalRawData) : base(SnakeKind.Cobra, length, serializedAdditionalRawData) => throw null; + internal Cobra(int length, IDictionary additionalBinaryDataProperties) : base(SnakeKind.Cobra, length, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Dog.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Dog.cs index 7168992da..81e900e61 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Dog.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Dog.cs @@ -11,7 +11,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { private protected Dog(DogKind kind, int weight) => throw null; - internal Dog(DogKind kind, int weight, IDictionary serializedAdditionalRawData) => throw null; + internal Dog(DogKind kind, int weight, IDictionary additionalBinaryDataProperties) => throw null; internal DogKind Kind { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Golden.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Golden.cs index fa887f76f..a48744fb6 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Golden.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Golden.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { public Golden(int weight) : base(DogKind.Golden, weight) => throw null; - internal Golden(int weight, IDictionary serializedAdditionalRawData) : base(DogKind.Golden, weight, serializedAdditionalRawData) => throw null; + internal Golden(int weight, IDictionary additionalBinaryDataProperties) : base(DogKind.Golden, weight, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Snake.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Snake.cs index 4855f39c0..bd6128d51 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Snake.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/Snake.cs @@ -11,7 +11,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { private protected Snake(SnakeKind kind, int length) => throw null; - internal Snake(SnakeKind kind, int length, IDictionary serializedAdditionalRawData) => throw null; + internal Snake(SnakeKind kind, int length, IDictionary additionalBinaryDataProperties) => throw null; internal SnakeKind Kind { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownDog.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownDog.cs index 090897391..58dbd4b66 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownDog.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownDog.cs @@ -9,6 +9,6 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { internal partial class UnknownDog : Dog { - internal UnknownDog(DogKind kind, int weight, IDictionary serializedAdditionalRawData) : base(kind != default ? kind : "unknown", weight, serializedAdditionalRawData) => throw null; + internal UnknownDog(DogKind kind, int weight, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", weight, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownSnake.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownSnake.cs index 4fdfbfe37..4d16468c3 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownSnake.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/Generated/Models/UnknownSnake.cs @@ -9,6 +9,6 @@ namespace _Type.Model.Inheritance.EnumDiscriminator.Models { internal partial class UnknownSnake : Snake { - internal UnknownSnake(SnakeKind kind, int length, IDictionary serializedAdditionalRawData) : base(kind, length, serializedAdditionalRawData) => throw null; + internal UnknownSnake(SnakeKind kind, int length, IDictionary additionalBinaryDataProperties) : base(kind, length, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs index 5b61bf605..63a9836fc 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs @@ -11,7 +11,7 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { private protected Bird(string kind, int wingspan) => throw null; - internal Bird(string kind, int wingspan, IDictionary serializedAdditionalRawData) => throw null; + internal Bird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) => throw null; internal string Kind { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs index 64415d276..9a3f9a23a 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs @@ -11,7 +11,7 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { private protected Dinosaur(string kind, int size) => throw null; - internal Dinosaur(string kind, int size, IDictionary serializedAdditionalRawData) => throw null; + internal Dinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) => throw null; internal string Kind { diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs index 1bdaea5d9..18f34d05b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs @@ -11,7 +11,7 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { public Eagle(int wingspan) : base("eagle", wingspan) => throw null; - internal Eagle(IList friends, IDictionary hate, Bird partner, int wingspan, IDictionary serializedAdditionalRawData) : base("eagle", wingspan, serializedAdditionalRawData) => throw null; + internal Eagle(IList friends, IDictionary hate, Bird partner, int wingspan, IDictionary additionalBinaryDataProperties) : base("eagle", wingspan, additionalBinaryDataProperties) => throw null; public IList Friends => throw null; diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs index 4930e2065..be30950ea 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { public Goose(int wingspan) : base("goose", wingspan) => throw null; - internal Goose(int wingspan, IDictionary serializedAdditionalRawData) : base("goose", wingspan, serializedAdditionalRawData) => throw null; + internal Goose(int wingspan, IDictionary additionalBinaryDataProperties) : base("goose", wingspan, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs index dc4b6d6b0..b6a21dbe3 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { public SeaGull(int wingspan) : base("seagull", wingspan) => throw null; - internal SeaGull(int wingspan, IDictionary serializedAdditionalRawData) : base("seagull", wingspan, serializedAdditionalRawData) => throw null; + internal SeaGull(int wingspan, IDictionary additionalBinaryDataProperties) : base("seagull", wingspan, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs index 7ca1cbfb7..54aadfefb 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { public Sparrow(int wingspan) : base("sparrow", wingspan) => throw null; - internal Sparrow(int wingspan, IDictionary serializedAdditionalRawData) : base("sparrow", wingspan, serializedAdditionalRawData) => throw null; + internal Sparrow(int wingspan, IDictionary additionalBinaryDataProperties) : base("sparrow", wingspan, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs index 2e6917993..9637050a9 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs @@ -11,6 +11,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { internal TRex(int size) : base("t-rex", size) => throw null; - internal TRex(int size, IDictionary serializedAdditionalRawData) : base("t-rex", size, serializedAdditionalRawData) => throw null; + internal TRex(int size, IDictionary additionalBinaryDataProperties) : base("t-rex", size, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs index 227db8279..c8f27a87b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs @@ -9,6 +9,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { internal partial class UnknownBird : Bird { - internal UnknownBird(string kind, int wingspan, IDictionary serializedAdditionalRawData) : base(kind ?? "unknown", wingspan, serializedAdditionalRawData) => throw null; + internal UnknownBird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", wingspan, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs index 9db770ebf..f338aa82a 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs @@ -9,6 +9,6 @@ namespace _Type.Model.Inheritance.SingleDiscriminator.Models { internal partial class UnknownDinosaur : Dinosaur { - internal UnknownDinosaur(string kind, int size, IDictionary serializedAdditionalRawData) : base(kind ?? "unknown", size, serializedAdditionalRawData) => throw null; + internal UnknownDinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", size, additionalBinaryDataProperties) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.Serialization.cs index 2d280af05..fceabac0c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.Serialization.cs @@ -106,9 +106,9 @@ namespace UnbrandedTypeSpec.Models { writer.WriteNull("requiredNullableList"u8); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -157,7 +157,7 @@ namespace UnbrandedTypeSpec.Models string requiredBadDescription = default; IList optionalNullableList = default; IList requiredNullableList = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -266,7 +266,7 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } return new AnonymousBodyRequest( @@ -283,7 +283,7 @@ namespace UnbrandedTypeSpec.Models requiredBadDescription, optionalNullableList ?? new ChangeTrackingList(), requiredNullableList, - serializedAdditionalRawData); + additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.cs index 5ee9288f8..137262519 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/AnonymousBodyRequest.cs @@ -14,7 +14,7 @@ namespace UnbrandedTypeSpec.Models internal partial class AnonymousBodyRequest { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal AnonymousBodyRequest(string name, BinaryData requiredUnion, string requiredBadDescription, IEnumerable requiredNullableList) { @@ -25,7 +25,7 @@ namespace UnbrandedTypeSpec.Models RequiredNullableList = requiredNullableList?.ToList(); } - internal AnonymousBodyRequest(string name, BinaryData requiredUnion, AnonymousBodyRequestRequiredLiteralString requiredLiteralString, AnonymousBodyRequestRequiredLiteralInt requiredLiteralInt, AnonymousBodyRequestRequiredLiteralFloat requiredLiteralFloat, bool requiredLiteralBool, AnonymousBodyRequestOptionalLiteralString? optionalLiteralString, AnonymousBodyRequestOptionalLiteralInt? optionalLiteralInt, AnonymousBodyRequestOptionalLiteralFloat? optionalLiteralFloat, bool? optionalLiteralBool, string requiredBadDescription, IList optionalNullableList, IList requiredNullableList, IDictionary serializedAdditionalRawData) + internal AnonymousBodyRequest(string name, BinaryData requiredUnion, AnonymousBodyRequestRequiredLiteralString requiredLiteralString, AnonymousBodyRequestRequiredLiteralInt requiredLiteralInt, AnonymousBodyRequestRequiredLiteralFloat requiredLiteralFloat, bool requiredLiteralBool, AnonymousBodyRequestOptionalLiteralString? optionalLiteralString, AnonymousBodyRequestOptionalLiteralInt? optionalLiteralInt, AnonymousBodyRequestOptionalLiteralFloat? optionalLiteralFloat, bool? optionalLiteralBool, string requiredBadDescription, IList optionalNullableList, IList requiredNullableList, IDictionary additionalBinaryDataProperties) { Name = name; RequiredUnion = requiredUnion; @@ -40,7 +40,7 @@ namespace UnbrandedTypeSpec.Models RequiredBadDescription = requiredBadDescription; OptionalNullableList = optionalNullableList; RequiredNullableList = requiredNullableList; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the Thing. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.Serialization.cs index 52185a769..75b0bf84d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.Serialization.cs @@ -36,9 +36,9 @@ namespace UnbrandedTypeSpec.Models } writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -75,7 +75,7 @@ namespace UnbrandedTypeSpec.Models return null; } string name = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -85,10 +85,10 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new Friend(name, serializedAdditionalRawData); + return new Friend(name, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.cs index d6315ff20..a3196307e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Friend.cs @@ -11,17 +11,17 @@ namespace UnbrandedTypeSpec.Models public partial class Friend { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal Friend(string name) { Name = name; } - internal Friend(string name, IDictionary serializedAdditionalRawData) + internal Friend(string name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the NotFriend. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.Serialization.cs index 6a676d651..50e971948 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.Serialization.cs @@ -36,9 +36,9 @@ namespace UnbrandedTypeSpec.Models } writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -75,7 +75,7 @@ namespace UnbrandedTypeSpec.Models return null; } string name = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -85,10 +85,10 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new FriendlyModelRequest(name, serializedAdditionalRawData); + return new FriendlyModelRequest(name, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.cs index 21dcabc53..8dcde6fab 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/FriendlyModelRequest.cs @@ -11,17 +11,17 @@ namespace UnbrandedTypeSpec.Models internal partial class FriendlyModelRequest { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal FriendlyModelRequest(string name) { Name = name; } - internal FriendlyModelRequest(string name, IDictionary serializedAdditionalRawData) + internal FriendlyModelRequest(string name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the NotFriend. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs index f89d12b6d..e9d46cb61 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs @@ -61,9 +61,9 @@ namespace UnbrandedTypeSpec.Models { writer.WriteNull("requiredFixedEnum"u8); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -102,7 +102,7 @@ namespace UnbrandedTypeSpec.Models int? requiredNullablePrimitive = default; StringExtensibleEnum? requiredExtensibleEnum = default; StringFixedEnum? requiredFixedEnum = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("requiredNullablePrimitive"u8)) @@ -137,10 +137,10 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ModelWithRequiredNullableProperties(requiredNullablePrimitive, requiredExtensibleEnum, requiredFixedEnum, serializedAdditionalRawData); + return new ModelWithRequiredNullableProperties(requiredNullablePrimitive, requiredExtensibleEnum, requiredFixedEnum, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.cs index c5fc361e8..7507960ef 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.cs @@ -11,7 +11,7 @@ namespace UnbrandedTypeSpec.Models public partial class ModelWithRequiredNullableProperties { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// required nullable primitive type. @@ -24,12 +24,12 @@ namespace UnbrandedTypeSpec.Models RequiredFixedEnum = requiredFixedEnum; } - internal ModelWithRequiredNullableProperties(int? requiredNullablePrimitive, StringExtensibleEnum? requiredExtensibleEnum, StringFixedEnum? requiredFixedEnum, IDictionary serializedAdditionalRawData) + internal ModelWithRequiredNullableProperties(int? requiredNullablePrimitive, StringExtensibleEnum? requiredExtensibleEnum, StringFixedEnum? requiredFixedEnum, IDictionary additionalBinaryDataProperties) { RequiredNullablePrimitive = requiredNullablePrimitive; RequiredExtensibleEnum = requiredExtensibleEnum; RequiredFixedEnum = requiredFixedEnum; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// required nullable primitive type. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.Serialization.cs index edae03387..e1838569d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.Serialization.cs @@ -36,9 +36,9 @@ namespace UnbrandedTypeSpec.Models } writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -75,7 +75,7 @@ namespace UnbrandedTypeSpec.Models return null; } string name = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -85,10 +85,10 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ProjectedModel(name, serializedAdditionalRawData); + return new ProjectedModel(name, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.cs index 86b7e880e..7299a9a92 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedModel.cs @@ -11,17 +11,17 @@ namespace UnbrandedTypeSpec.Models public partial class ProjectedModel { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal ProjectedModel(string name) { Name = name; } - internal ProjectedModel(string name, IDictionary serializedAdditionalRawData) + internal ProjectedModel(string name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the ModelWithProjectedName. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.Serialization.cs index 05c39e5ad..5f3e70afa 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.Serialization.cs @@ -36,9 +36,9 @@ namespace UnbrandedTypeSpec.Models } writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -75,7 +75,7 @@ namespace UnbrandedTypeSpec.Models return null; } string name = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -85,10 +85,10 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ProjectedNameModelRequest(name, serializedAdditionalRawData); + return new ProjectedNameModelRequest(name, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.cs index 55848cbfa..d5a71d702 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ProjectedNameModelRequest.cs @@ -11,17 +11,17 @@ namespace UnbrandedTypeSpec.Models internal partial class ProjectedNameModelRequest { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal ProjectedNameModelRequest(string name) { Name = name; } - internal ProjectedNameModelRequest(string name, IDictionary serializedAdditionalRawData) + internal ProjectedNameModelRequest(string name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the ModelWithProjectedName. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs index 6cef383a2..2fe54b82a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs @@ -30,9 +30,9 @@ namespace UnbrandedTypeSpec.Models { throw new FormatException($"The model {nameof(ReturnsAnonymousModelResponse)} does not support writing '{format}' format."); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -68,15 +68,15 @@ namespace UnbrandedTypeSpec.Models { return null; } - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ReturnsAnonymousModelResponse(serializedAdditionalRawData); + return new ReturnsAnonymousModelResponse(additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.cs index 2508da8e7..f9770f6d1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.cs @@ -11,15 +11,15 @@ namespace UnbrandedTypeSpec.Models public partial class ReturnsAnonymousModelResponse { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; internal ReturnsAnonymousModelResponse() { } - internal ReturnsAnonymousModelResponse(IDictionary serializedAdditionalRawData) + internal ReturnsAnonymousModelResponse(IDictionary additionalBinaryDataProperties) { - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs index a76f7a5f0..e4c8f5244 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs @@ -244,9 +244,9 @@ namespace UnbrandedTypeSpec.Models writer.WriteObjectValue(ModelWithRequiredNullable, options); writer.WritePropertyName("requiredBytes"u8); writer.WriteBase64StringValue(RequiredBytes.ToArray(), "D"); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -306,7 +306,7 @@ namespace UnbrandedTypeSpec.Models IReadOnlyDictionary readOnlyOptionalRecordUnknown = default; ModelWithRequiredNullableProperties modelWithRequiredNullable = default; BinaryData requiredBytes = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("requiredString"u8)) @@ -573,7 +573,7 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } return new RoundTripModel( @@ -601,7 +601,7 @@ namespace UnbrandedTypeSpec.Models readOnlyOptionalRecordUnknown ?? new ChangeTrackingDictionary(), modelWithRequiredNullable, requiredBytes, - serializedAdditionalRawData); + additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.cs index 3739e072a..ca0e1eecc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/RoundTripModel.cs @@ -14,7 +14,7 @@ namespace UnbrandedTypeSpec.Models public partial class RoundTripModel { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Required string, illustrating a reference type property. @@ -56,7 +56,7 @@ namespace UnbrandedTypeSpec.Models RequiredBytes = requiredBytes; } - internal RoundTripModel(string requiredString, int requiredInt, IList requiredCollection, IDictionary requiredDictionary, Thing requiredModel, IntExtensibleEnum? intExtensibleEnum, IList intExtensibleEnumCollection, FloatExtensibleEnum? floatExtensibleEnum, FloatExtensibleEnumWithIntValue? floatExtensibleEnumWithIntValue, IList floatExtensibleEnumCollection, FloatFixedEnum? floatFixedEnum, FloatFixedEnumWithIntValue? floatFixedEnumWithIntValue, IList floatFixedEnumCollection, IntFixedEnum? intFixedEnum, IList intFixedEnumCollection, StringFixedEnum? stringFixedEnum, BinaryData requiredUnknown, BinaryData optionalUnknown, IDictionary requiredRecordUnknown, IDictionary optionalRecordUnknown, IReadOnlyDictionary readOnlyRequiredRecordUnknown, IReadOnlyDictionary readOnlyOptionalRecordUnknown, ModelWithRequiredNullableProperties modelWithRequiredNullable, BinaryData requiredBytes, IDictionary serializedAdditionalRawData) + internal RoundTripModel(string requiredString, int requiredInt, IList requiredCollection, IDictionary requiredDictionary, Thing requiredModel, IntExtensibleEnum? intExtensibleEnum, IList intExtensibleEnumCollection, FloatExtensibleEnum? floatExtensibleEnum, FloatExtensibleEnumWithIntValue? floatExtensibleEnumWithIntValue, IList floatExtensibleEnumCollection, FloatFixedEnum? floatFixedEnum, FloatFixedEnumWithIntValue? floatFixedEnumWithIntValue, IList floatFixedEnumCollection, IntFixedEnum? intFixedEnum, IList intFixedEnumCollection, StringFixedEnum? stringFixedEnum, BinaryData requiredUnknown, BinaryData optionalUnknown, IDictionary requiredRecordUnknown, IDictionary optionalRecordUnknown, IReadOnlyDictionary readOnlyRequiredRecordUnknown, IReadOnlyDictionary readOnlyOptionalRecordUnknown, ModelWithRequiredNullableProperties modelWithRequiredNullable, BinaryData requiredBytes, IDictionary additionalBinaryDataProperties) { RequiredString = requiredString; RequiredInt = requiredInt; @@ -82,7 +82,7 @@ namespace UnbrandedTypeSpec.Models ReadOnlyOptionalRecordUnknown = readOnlyOptionalRecordUnknown; ModelWithRequiredNullable = modelWithRequiredNullable; RequiredBytes = requiredBytes; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Required string, illustrating a reference type property. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.Serialization.cs index 323d56091..2d140b1a4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.Serialization.cs @@ -106,9 +106,9 @@ namespace UnbrandedTypeSpec.Models { writer.WriteNull("requiredNullableList"u8); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER @@ -157,7 +157,7 @@ namespace UnbrandedTypeSpec.Models string requiredBadDescription = default; IList optionalNullableList = default; IList requiredNullableList = default; - IDictionary serializedAdditionalRawData = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("name"u8)) @@ -266,7 +266,7 @@ namespace UnbrandedTypeSpec.Models } if (options.Format != "W") { - serializedAdditionalRawData.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } return new Thing( @@ -283,7 +283,7 @@ namespace UnbrandedTypeSpec.Models requiredBadDescription, optionalNullableList ?? new ChangeTrackingList(), requiredNullableList, - serializedAdditionalRawData); + additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.cs index 3a0713432..32fc3d217 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/Models/Thing.cs @@ -14,7 +14,7 @@ namespace UnbrandedTypeSpec.Models public partial class Thing { /// Keeps track of any properties unknown to the library. - private protected IDictionary _serializedAdditionalRawData; + private protected IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// name of the Thing. @@ -35,7 +35,7 @@ namespace UnbrandedTypeSpec.Models RequiredNullableList = requiredNullableList?.ToList(); } - internal Thing(string name, BinaryData requiredUnion, ThingRequiredLiteralString requiredLiteralString, ThingRequiredLiteralInt requiredLiteralInt, ThingRequiredLiteralFloat requiredLiteralFloat, bool requiredLiteralBool, ThingOptionalLiteralString? optionalLiteralString, ThingOptionalLiteralInt? optionalLiteralInt, ThingOptionalLiteralFloat? optionalLiteralFloat, bool? optionalLiteralBool, string requiredBadDescription, IList optionalNullableList, IList requiredNullableList, IDictionary serializedAdditionalRawData) + internal Thing(string name, BinaryData requiredUnion, ThingRequiredLiteralString requiredLiteralString, ThingRequiredLiteralInt requiredLiteralInt, ThingRequiredLiteralFloat requiredLiteralFloat, bool requiredLiteralBool, ThingOptionalLiteralString? optionalLiteralString, ThingOptionalLiteralInt? optionalLiteralInt, ThingOptionalLiteralFloat? optionalLiteralFloat, bool? optionalLiteralBool, string requiredBadDescription, IList optionalNullableList, IList requiredNullableList, IDictionary additionalBinaryDataProperties) { Name = name; RequiredUnion = requiredUnion; @@ -50,7 +50,7 @@ namespace UnbrandedTypeSpec.Models RequiredBadDescription = requiredBadDescription; OptionalNullableList = optionalNullableList; RequiredNullableList = requiredNullableList; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// name of the Thing.