diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index db9ff59fe914b..f2b9e6b8f5c1f 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -209,7 +209,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + diff --git a/eng/emitter-package-lock.json b/eng/emitter-package-lock.json index a07ebbb568fbc..4295252a3e12d 100644 --- a/eng/emitter-package-lock.json +++ b/eng/emitter-package-lock.json @@ -5,21 +5,22 @@ "packages": { "": { "dependencies": { - "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240216.2.tgz" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240221.4.tgz" }, "devDependencies": { "@azure-tools/typespec-azure-core": "0.38.0", "@azure-tools/typespec-client-generator-core": "0.38.0", "@typespec/compiler": "0.52.0", "@typespec/http": "0.52.1", + "@typespec/openapi": "0.52.0", "@typespec/rest": "0.52.0", "@typespec/versioning": "0.52.0" } }, "node_modules/@autorest/csharp": { - "version": "3.0.0-alpha.20240216.2", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240216.2.tgz", - "integrity": "sha512-dVGNvxmNs9RnKw4RB+3z2dQEd4/TISDWx+b1wlanAKAYab61feb3DKWAnSaBPjwLA3zzIvlmkwDnt3mVZKg1LA==" + "version": "3.0.0-alpha.20240221.4", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240221.4.tgz", + "integrity": "sha512-2GSCXTH8B3hozRYDDDJkHYV7jgZIfVVx2Ng362RY5EQculX/XnlF9xm7+w9ZMHmcGy0VpHFvXxH5PnTjihV8Wg==" }, "node_modules/@azure-tools/typespec-azure-core": { "version": "0.38.0", @@ -55,12 +56,12 @@ } }, "node_modules/@azure-tools/typespec-csharp": { - "version": "0.2.0-alpha.20240216.2", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240216.2.tgz", - "integrity": "sha512-xpBv68Mtu9M02Y4ZRKapmf/hUaOaTmhdU4VBGGe6++7yFVEVSGFlNoUVwE7V/+Y2Oj8sq9p6/8hyu0nZqJ2oRQ==", + "version": "0.2.0-alpha.20240221.4", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240221.4.tgz", + "integrity": "sha512-OCzpUdv0o19tjDJisbZJoWaQiv9hxS/Tu0zBKZ1dSAse5N8e42pxEBlOGQGZrNPa/+grPbXVYrWAHIbIEHwT5g==", "license": "MIT", "dependencies": { - "@autorest/csharp": "3.0.0-alpha.20240216.2", + "@autorest/csharp": "3.0.0-alpha.20240221.4", "json-serialize-refs": "0.1.0-0", "winston": "^3.8.2" }, @@ -69,6 +70,7 @@ "@azure-tools/typespec-client-generator-core": ">=0.36.0 <1.0.0", "@typespec/compiler": ">=0.50.0 <1.0.0", "@typespec/http": ">=0.50.0 <1.0.0", + "@typespec/openapi": ">=0.50.0 <1.0.0", "@typespec/rest": ">=0.50.0 <1.0.0", "@typespec/versioning": ">=0.50.0 <1.0.0" } @@ -163,9 +165,9 @@ } }, "node_modules/@sindresorhus/merge-streams": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.2.1.tgz", - "integrity": "sha512-255V7MMIKw6aQ43Wbqp9HZ+VHn6acddERTLiiLnlcPLU9PdTq9Aijl12oklAgUEblLWye+vHLzmqBx6f2TGcZw==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", + "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==", "dev": true, "engines": { "node": ">=18" @@ -219,6 +221,19 @@ "@typespec/compiler": "~0.52.0" } }, + "node_modules/@typespec/openapi": { + "version": "0.52.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.52.0.tgz", + "integrity": "sha512-2Otnu9glehxvp6TU7NOHEniBDDKufV03XTmeVGgGEmu/j+cveAMg8lA1/O0RBpS2oHGsCFnMEuPcR8M1c0LI+Q==", + "dev": true, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.52.0", + "@typespec/http": "~0.52.0" + } + }, "node_modules/@typespec/rest": { "version": "0.52.0", "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.52.0.tgz", @@ -1188,4 +1203,4 @@ } } } -} +} \ No newline at end of file diff --git a/eng/emitter-package.json b/eng/emitter-package.json index 6ab0c1a00e752..366dc50b47740 100644 --- a/eng/emitter-package.json +++ b/eng/emitter-package.json @@ -1,17 +1,18 @@ { "main": "dist/src/index.js", "dependencies": { - "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240216.2.tgz" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240221.4.tgz" }, "devDependencies": { "@typespec/compiler": "0.52.0", - "@typespec/http": "0.52.1", "@typespec/rest": "0.52.0", - "@azure-tools/typespec-client-generator-core": "0.38.0", "@azure-tools/typespec-azure-core": "0.38.0", - "@typespec/versioning": "0.52.0" + "@typespec/openapi": "0.52.0", + "@typespec/versioning": "0.52.0", + "@azure-tools/typespec-client-generator-core": "0.38.0", + "@typespec/http": "0.52.1" }, "overrides": { - "@autorest/csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240216.2.tgz" + "@autorest/csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240221.4.tgz" } -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationKeyValueData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationKeyValueData.Serialization.cs index 0cd7845c9bb2e..01b200034c3df 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationKeyValueData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationKeyValueData.Serialization.cs @@ -274,21 +274,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -296,28 +296,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -326,21 +326,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Key.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Key}'''"); } else { - builder.AppendLine($" '{Key}'"); + builder.AppendLine($"'{Key}'"); } } } @@ -348,21 +348,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Label), out propertyOverride); if (Optional.IsDefined(Label) || hasPropertyOverride) { - builder.Append(" label:"); + builder.Append(" label: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Label.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Label}'''"); } else { - builder.AppendLine($" '{Label}'"); + builder.AppendLine($"'{Label}'"); } } } @@ -370,21 +370,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -392,21 +392,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); if (Optional.IsDefined(ContentType) || hasPropertyOverride) { - builder.Append(" contentType:"); + builder.Append(" contentType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentType}'''"); } else { - builder.AppendLine($" '{ContentType}'"); + builder.AppendLine($"'{ContentType}'"); } } } @@ -414,44 +414,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" eTag:"); + builder.Append(" eTag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModified:"); + builder.Append(" lastModified: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocked), out propertyOverride); if (Optional.IsDefined(IsLocked) || hasPropertyOverride) { - builder.Append(" locked:"); + builder.Append(" locked: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLocked.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -460,17 +460,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -478,12 +478,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -496,12 +496,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -522,13 +525,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateEndpointConnectionData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateEndpointConnectionData.Serialization.cs index 7a1ea9cd664fe..0d521b1a16b6e 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateEndpointConnectionData.Serialization.cs @@ -175,7 +175,7 @@ internal static AppConfigurationPrivateEndpointConnectionData DeserializeAppConf { continue; } - privateLinkServiceConnectionState = AppConfigurationPrivateLinkServiceConnectionState.DeserializeAppConfigurationPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = AppConfigurationPrivateLinkServiceConnectionState.DeserializeAppConfigurationPrivateLinkServiceConnectionState(property0.Value); continue; } } @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -226,28 +226,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -256,42 +256,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } @@ -300,12 +300,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -326,13 +329,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateLinkResourceData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateLinkResourceData.Serialization.cs index 43442f340b922..93e8efd249025 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateLinkResourceData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationPrivateLinkResourceData.Serialization.cs @@ -219,21 +219,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -241,28 +241,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -271,21 +271,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -295,14 +295,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -330,14 +330,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -365,12 +365,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -391,13 +394,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationReplicaData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationReplicaData.Serialization.cs index adf43a8ad55c5..79afac94520e9 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationReplicaData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationReplicaData.Serialization.cs @@ -199,21 +199,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -221,42 +221,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -265,21 +265,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Endpoint), out propertyOverride); if (Optional.IsDefined(Endpoint) || hasPropertyOverride) { - builder.Append(" endpoint:"); + builder.Append(" endpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Endpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Endpoint}'''"); } else { - builder.AppendLine($" '{Endpoint}'"); + builder.AppendLine($"'{Endpoint}'"); } } } @@ -287,14 +287,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationStoreData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationStoreData.Serialization.cs index 3a78432478fb7..b85e1b80234ea 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationStoreData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/AppConfigurationStoreData.Serialization.cs @@ -207,7 +207,7 @@ internal static AppConfigurationStoreData DeserializeAppConfigurationStoreData(J } if (property.NameEquals("sku"u8)) { - sku = AppConfigurationSku.DeserializeAppConfigurationSku(property.Value, options); + sku = AppConfigurationSku.DeserializeAppConfigurationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -291,7 +291,7 @@ internal static AppConfigurationStoreData DeserializeAppConfigurationStoreData(J { continue; } - encryption = AppConfigurationStoreEncryptionProperties.DeserializeAppConfigurationStoreEncryptionProperties(property0.Value, options); + encryption = AppConfigurationStoreEncryptionProperties.DeserializeAppConfigurationStoreEncryptionProperties(property0.Value); continue; } if (property0.NameEquals("privateEndpointConnections"u8)) @@ -304,7 +304,7 @@ internal static AppConfigurationStoreData DeserializeAppConfigurationStoreData(J List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(AppConfigurationPrivateEndpointConnectionReference.DeserializeAppConfigurationPrivateEndpointConnectionReference(item, options)); + array.Add(AppConfigurationPrivateEndpointConnectionReference.DeserializeAppConfigurationPrivateEndpointConnectionReference(item)); } privateEndpointConnections = array; continue; @@ -380,21 +380,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -402,14 +402,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -418,17 +418,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -436,12 +436,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -452,56 +452,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -510,50 +510,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Endpoint), out propertyOverride); if (Optional.IsDefined(Endpoint) || hasPropertyOverride) { - builder.Append(" endpoint:"); + builder.Append(" endpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Endpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Endpoint}'''"); } else { - builder.AppendLine($" '{Endpoint}'"); + builder.AppendLine($"'{Endpoint}'"); } } } @@ -561,14 +561,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Encryption), out propertyOverride); if (Optional.IsDefined(Encryption) || hasPropertyOverride) { - builder.Append(" encryption:"); + builder.Append(" encryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Encryption, options, 4, false); + AppendChildObject(builder, Encryption, options, 4, false, " encryption: "); } } @@ -577,17 +577,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -597,72 +597,72 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicNetworkAccess.Value.ToString()}'"); + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisableLocalAuth), out propertyOverride); if (Optional.IsDefined(DisableLocalAuth) || hasPropertyOverride) { - builder.Append(" disableLocalAuth:"); + builder.Append(" disableLocalAuth: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = DisableLocalAuth.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SoftDeleteRetentionInDays), out propertyOverride); if (Optional.IsDefined(SoftDeleteRetentionInDays) || hasPropertyOverride) { - builder.Append(" softDeleteRetentionInDays:"); + builder.Append(" softDeleteRetentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SoftDeleteRetentionInDays.Value}"); + builder.AppendLine($"{SoftDeleteRetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnablePurgeProtection), out propertyOverride); if (Optional.IsDefined(EnablePurgeProtection) || hasPropertyOverride) { - builder.Append(" enablePurgeProtection:"); + builder.Append(" enablePurgeProtection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnablePurgeProtection.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); if (Optional.IsDefined(CreateMode) || hasPropertyOverride) { - builder.Append(" createMode:"); + builder.Append(" createMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{CreateMode.Value.ToSerialString()}'"); } } @@ -671,12 +671,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -697,13 +700,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/DeletedAppConfigurationStoreData.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/DeletedAppConfigurationStoreData.Serialization.cs index 930322004111a..bd21003bc4c64 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/DeletedAppConfigurationStoreData.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/DeletedAppConfigurationStoreData.Serialization.cs @@ -259,21 +259,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -281,28 +281,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -311,58 +311,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConfigurationStoreId), out propertyOverride); if (Optional.IsDefined(ConfigurationStoreId) || hasPropertyOverride) { - builder.Append(" configurationStoreId:"); + builder.Append(" configurationStoreId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ConfigurationStoreId.ToString()}'"); + builder.AppendLine($"'{ConfigurationStoreId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionDate:"); + builder.Append(" deletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduledPurgeOn), out propertyOverride); if (Optional.IsDefined(ScheduledPurgeOn) || hasPropertyOverride) { - builder.Append(" scheduledPurgeDate:"); + builder.Append(" scheduledPurgeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ScheduledPurgeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -371,17 +371,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -389,12 +389,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -405,15 +405,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPurgeProtectionEnabled), out propertyOverride); if (Optional.IsDefined(IsPurgeProtectionEnabled) || hasPropertyOverride) { - builder.Append(" purgeProtectionEnabled:"); + builder.Append(" purgeProtectionEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPurgeProtectionEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -422,12 +422,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -448,13 +451,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationKeyVaultProperties.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationKeyVaultProperties.Serialization.cs index d1c962a95676e..7af373a9fb608 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationKeyVaultProperties.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationKeyVaultProperties.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyIdentifier), out propertyOverride); if (Optional.IsDefined(KeyIdentifier) || hasPropertyOverride) { - builder.Append(" keyIdentifier:"); + builder.Append(" keyIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyIdentifier}'''"); } else { - builder.AppendLine($" '{KeyIdentifier}'"); + builder.AppendLine($"'{KeyIdentifier}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityClientId), out propertyOverride); if (Optional.IsDefined(IdentityClientId) || hasPropertyOverride) { - builder.Append(" identityClientId:"); + builder.Append(" identityClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (IdentityClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{IdentityClientId}'''"); } else { - builder.AppendLine($" '{IdentityClientId}'"); + builder.AppendLine($"'{IdentityClientId}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationNameAvailabilityResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationNameAvailabilityResult.Serialization.cs index 683bf82265692..a55827d78738e 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationNameAvailabilityResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationNameAvailabilityResult.Serialization.cs @@ -130,36 +130,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsNameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -190,12 +190,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -216,13 +219,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionListResult.Serialization.cs index 0156f7e1d9c66..4b50b96d92ae1 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static AppConfigurationPrivateEndpointConnectionListResult DeserializeA List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AppConfigurationPrivateEndpointConnectionData.DeserializeAppConfigurationPrivateEndpointConnectionData(item, options)); + array.Add(AppConfigurationPrivateEndpointConnectionData.DeserializeAppConfigurationPrivateEndpointConnectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionReference.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionReference.Serialization.cs index b6fdda488ae74..475edda2161e2 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionReference.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateEndpointConnectionReference.Serialization.cs @@ -174,7 +174,7 @@ internal static AppConfigurationPrivateEndpointConnectionReference DeserializeAp { continue; } - privateLinkServiceConnectionState = AppConfigurationPrivateLinkServiceConnectionState.DeserializeAppConfigurationPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = AppConfigurationPrivateLinkServiceConnectionState.DeserializeAppConfigurationPrivateLinkServiceConnectionState(property0.Value); continue; } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,28 +225,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -255,42 +255,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } @@ -299,12 +299,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -325,13 +328,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkResourceListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkResourceListResult.Serialization.cs index 0df8e1ad43ec7..4b7f2e55c26aa 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkResourceListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static AppConfigurationPrivateLinkResourceListResult DeserializeAppConf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AppConfigurationPrivateLinkResourceData.DeserializeAppConfigurationPrivateLinkResourceData(item, options)); + array.Add(AppConfigurationPrivateLinkResourceData.DeserializeAppConfigurationPrivateLinkResourceData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkServiceConnectionState.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkServiceConnectionState.Serialization.cs index d82e2ef6ea5b5..4bcea68fa0d6e 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationPrivateLinkServiceConnectionState.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -170,14 +170,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionsRequired.Value.ToString()}'"); + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationSku.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationSku.Serialization.cs index 615d402e2e2d5..f796fe8b4c145 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationSku.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationSku.Serialization.cs @@ -101,21 +101,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKey.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKey.Serialization.cs index 57d06dcd1b1de..7c17531b62a71 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKey.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKey.Serialization.cs @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -189,21 +189,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionString), out propertyOverride); if (Optional.IsDefined(ConnectionString) || hasPropertyOverride) { - builder.Append(" connectionString:"); + builder.Append(" connectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionString}'''"); } else { - builder.AppendLine($" '{ConnectionString}'"); + builder.AppendLine($"'{ConnectionString}'"); } } } @@ -255,30 +255,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModified:"); + builder.Append(" lastModified: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReadOnly), out propertyOverride); if (Optional.IsDefined(IsReadOnly) || hasPropertyOverride) { - builder.Append(" readOnly:"); + builder.Append(" readOnly: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReadOnly.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -286,12 +286,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -312,13 +315,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKeyListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKeyListResult.Serialization.cs index 735eb6cc2291c..d0a04267fdd5d 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKeyListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreApiKeyListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static AppConfigurationStoreApiKeyListResult DeserializeAppConfiguratio List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AppConfigurationStoreApiKey.DeserializeAppConfigurationStoreApiKey(item, options)); + array.Add(AppConfigurationStoreApiKey.DeserializeAppConfigurationStoreApiKey(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreEncryptionProperties.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreEncryptionProperties.Serialization.cs index cf50aeebbf8cd..a74564f312c1b 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreEncryptionProperties.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreEncryptionProperties.Serialization.cs @@ -90,7 +90,7 @@ internal static AppConfigurationStoreEncryptionProperties DeserializeAppConfigur keyVaultProperties = null; continue; } - keyVaultProperties = AppConfigurationKeyVaultProperties.DeserializeAppConfigurationKeyVaultProperties(property.Value, options); + keyVaultProperties = AppConfigurationKeyVaultProperties.DeserializeAppConfigurationKeyVaultProperties(property.Value); continue; } if (options.Format != "W") @@ -116,14 +116,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) { - builder.Append(" keyVaultProperties:"); + builder.Append(" keyVaultProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyVaultProperties, options, 2, false); + AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); } } @@ -131,12 +131,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -157,13 +160,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreListResult.Serialization.cs index 437f5f8c62cd6..421772a109bd2 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStoreListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static AppConfigurationStoreListResult DeserializeAppConfigurationStore List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AppConfigurationStoreData.DeserializeAppConfigurationStoreData(item, options)); + array.Add(AppConfigurationStoreData.DeserializeAppConfigurationStoreData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStorePatch.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStorePatch.Serialization.cs index cc9fa865f6dde..dbf581eed2f41 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStorePatch.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/AppConfigurationStorePatch.Serialization.cs @@ -135,7 +135,7 @@ internal static AppConfigurationStorePatch DeserializeAppConfigurationStorePatch { continue; } - sku = AppConfigurationSku.DeserializeAppConfigurationSku(property.Value, options); + sku = AppConfigurationSku.DeserializeAppConfigurationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -167,7 +167,7 @@ internal static AppConfigurationStorePatch DeserializeAppConfigurationStorePatch { continue; } - encryption = AppConfigurationStoreEncryptionProperties.DeserializeAppConfigurationStoreEncryptionProperties(property0.Value, options); + encryption = AppConfigurationStoreEncryptionProperties.DeserializeAppConfigurationStoreEncryptionProperties(property0.Value); continue; } if (property0.NameEquals("disableLocalAuth"u8)) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/DeletedConfigurationStoreListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/DeletedConfigurationStoreListResult.Serialization.cs index b13e28ab61e71..37473ef807ff2 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/DeletedConfigurationStoreListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/DeletedConfigurationStoreListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DeletedConfigurationStoreListResult DeserializeDeletedConfigurat List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeletedAppConfigurationStoreData.DeserializeDeletedAppConfigurationStoreData(item, options)); + array.Add(DeletedAppConfigurationStoreData.DeserializeDeletedAppConfigurationStoreData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/ReplicaListResult.Serialization.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/ReplicaListResult.Serialization.cs index 4da6fd350653a..943826cb7704a 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/ReplicaListResult.Serialization.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/Models/ReplicaListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ReplicaListResult DeserializeReplicaListResult(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AppConfigurationReplicaData.DeserializeAppConfigurationReplicaData(item, options)); + array.Add(AppConfigurationReplicaData.DeserializeAppConfigurationReplicaData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultData.Serialization.cs index 780e4c2a8e18b..a9058d346949a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultData.Serialization.cs @@ -108,7 +108,7 @@ internal static DeletedKeyVaultData DeserializeDeletedKeyVaultData(JsonElement e { continue; } - properties = DeletedKeyVaultProperties.DeserializeDeletedKeyVaultProperties(property.Value, options); + properties = DeletedKeyVaultProperties.DeserializeDeletedKeyVaultProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,42 +180,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmData.Serialization.cs index cd95d2687993f..cf70bce3ff49a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmData.Serialization.cs @@ -108,7 +108,7 @@ internal static DeletedManagedHsmData DeserializeDeletedManagedHsmData(JsonEleme { continue; } - properties = DeletedManagedHsmProperties.DeserializeDeletedManagedHsmProperties(property.Value, options); + properties = DeletedManagedHsmProperties.DeserializeDeletedManagedHsmProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,42 +180,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultData.Serialization.cs index 6def086bb3f29..4b87ffa66b8d3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultData.Serialization.cs @@ -117,7 +117,7 @@ internal static KeyVaultData DeserializeKeyVaultData(JsonElement element, ModelR { if (property.NameEquals("properties"u8)) { - properties = Models.KeyVaultProperties.DeserializeKeyVaultProperties(property.Value, options); + properties = Models.KeyVaultProperties.DeserializeKeyVaultProperties(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -186,21 +186,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -208,14 +208,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -224,17 +224,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -242,12 +242,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -258,42 +258,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -301,12 +301,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -327,13 +330,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionData.Serialization.cs index 2eccb621e9ef9..53ceebe4a22e9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionData.Serialization.cs @@ -224,7 +224,7 @@ internal static KeyVaultPrivateEndpointConnectionData DeserializeKeyVaultPrivate { continue; } - privateLinkServiceConnectionState = KeyVaultPrivateLinkServiceConnectionState.DeserializeKeyVaultPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = KeyVaultPrivateLinkServiceConnectionState.DeserializeKeyVaultPrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -284,14 +284,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -300,17 +300,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -318,12 +318,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -334,42 +334,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -378,42 +378,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -422,12 +422,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -448,13 +451,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretData.Serialization.cs index e66fb7328a849..012982012f77c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretData.Serialization.cs @@ -120,7 +120,7 @@ internal static KeyVaultSecretData DeserializeKeyVaultSecretData(JsonElement ele { if (property.NameEquals("properties"u8)) { - properties = SecretProperties.DeserializeSecretProperties(property.Value, options); + properties = SecretProperties.DeserializeSecretProperties(property.Value); continue; } if (property.NameEquals("location"u8)) @@ -193,21 +193,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -215,14 +215,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -231,17 +231,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -249,12 +249,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -265,42 +265,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -308,12 +308,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -334,13 +337,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs index d4f93bc69fd34..c47b39737aac7 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs @@ -130,7 +130,7 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element, Mo { continue; } - properties = ManagedHsmProperties.DeserializeManagedHsmProperties(property.Value, options); + properties = ManagedHsmProperties.DeserializeManagedHsmProperties(property.Value); continue; } if (property.NameEquals("sku"u8)) @@ -139,7 +139,7 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element, Mo { continue; } - sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); + sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -208,21 +208,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -230,14 +230,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -246,17 +246,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -264,12 +264,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -280,56 +280,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -337,12 +337,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -363,13 +366,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs index 8166fe223bdc3..2b00445fc1e65 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs @@ -162,7 +162,7 @@ internal static ManagedHsmPrivateEndpointConnectionData DeserializeManagedHsmPri { continue; } - sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); + sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -232,7 +232,7 @@ internal static ManagedHsmPrivateEndpointConnectionData DeserializeManagedHsmPri { continue; } - privateLinkServiceConnectionState = ManagedHsmPrivateLinkServiceConnectionState.DeserializeManagedHsmPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = ManagedHsmPrivateLinkServiceConnectionState.DeserializeManagedHsmPrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -270,21 +270,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -292,14 +292,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -308,17 +308,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -326,12 +326,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -342,56 +342,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -400,42 +400,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -444,12 +444,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -470,13 +473,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedKeyVaultProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedKeyVaultProperties.Serialization.cs index 826382a9a1abb..1a4d11cc97e61 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedKeyVaultProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedKeyVaultProperties.Serialization.cs @@ -195,14 +195,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -211,17 +211,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -229,12 +229,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -245,59 +245,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VaultId), out propertyOverride); if (Optional.IsDefined(VaultId) || hasPropertyOverride) { - builder.Append(" vaultId:"); + builder.Append(" vaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VaultId.ToString()}'"); + builder.AppendLine($"'{VaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionDate:"); + builder.Append(" deletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduledPurgeOn), out propertyOverride); if (Optional.IsDefined(ScheduledPurgeOn) || hasPropertyOverride) { - builder.Append(" scheduledPurgeDate:"); + builder.Append(" scheduledPurgeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ScheduledPurgeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PurgeProtectionEnabled), out propertyOverride); if (Optional.IsDefined(PurgeProtectionEnabled) || hasPropertyOverride) { - builder.Append(" purgeProtectionEnabled:"); + builder.Append(" purgeProtectionEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = PurgeProtectionEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -305,12 +305,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -331,13 +334,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmListResult.Serialization.cs index a4a36b1307229..0d7500182ada5 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DeletedManagedHsmListResult DeserializeDeletedManagedHsmListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeletedManagedHsmData.DeserializeDeletedManagedHsmData(item, options)); + array.Add(DeletedManagedHsmData.DeserializeDeletedManagedHsmData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmProperties.Serialization.cs index c68eec4af7f00..1665f5544ec4f 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedManagedHsmProperties.Serialization.cs @@ -195,14 +195,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -211,17 +211,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -229,12 +229,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -245,59 +245,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedHsmId), out propertyOverride); if (Optional.IsDefined(ManagedHsmId) || hasPropertyOverride) { - builder.Append(" mhsmId:"); + builder.Append(" mhsmId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedHsmId.ToString()}'"); + builder.AppendLine($"'{ManagedHsmId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionDate:"); + builder.Append(" deletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduledPurgeOn), out propertyOverride); if (Optional.IsDefined(ScheduledPurgeOn) || hasPropertyOverride) { - builder.Append(" scheduledPurgeDate:"); + builder.Append(" scheduledPurgeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ScheduledPurgeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PurgeProtectionEnabled), out propertyOverride); if (Optional.IsDefined(PurgeProtectionEnabled) || hasPropertyOverride) { - builder.Append(" purgeProtectionEnabled:"); + builder.Append(" purgeProtectionEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = PurgeProtectionEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -305,12 +305,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -331,13 +334,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedVaultListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedVaultListResult.Serialization.cs index ea904d0de8c99..cc8ac3dfc00dc 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedVaultListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletedVaultListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DeletedVaultListResult DeserializeDeletedVaultListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeletedKeyVaultData.DeserializeDeletedKeyVaultData(item, options)); + array.Add(DeletedKeyVaultData.DeserializeDeletedKeyVaultData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/IdentityAccessPermissions.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/IdentityAccessPermissions.Serialization.cs index 804974dca3042..949decab0911d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/IdentityAccessPermissions.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/IdentityAccessPermissions.Serialization.cs @@ -196,14 +196,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Keys.Any() || hasPropertyOverride) { - builder.Append(" keys:"); + builder.Append(" keys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Keys) { builder.AppendLine($" '{item.ToString()}'"); @@ -218,14 +218,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Secrets.Any() || hasPropertyOverride) { - builder.Append(" secrets:"); + builder.Append(" secrets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Secrets) { builder.AppendLine($" '{item.ToString()}'"); @@ -240,14 +240,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Certificates.Any() || hasPropertyOverride) { - builder.Append(" certificates:"); + builder.Append(" certificates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Certificates) { builder.AppendLine($" '{item.ToString()}'"); @@ -262,14 +262,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Storage.Any() || hasPropertyOverride) { - builder.Append(" storage:"); + builder.Append(" storage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Storage) { builder.AppendLine($" '{item.ToString()}'"); @@ -283,12 +283,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -309,13 +312,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicy.Serialization.cs index 4768740021801..d837e47613389 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicy.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicy.Serialization.cs @@ -106,7 +106,7 @@ internal static KeyVaultAccessPolicy DeserializeKeyVaultAccessPolicy(JsonElement } if (property.NameEquals("permissions"u8)) { - permissions = IdentityAccessPermissions.DeserializeIdentityAccessPermissions(property.Value, options); + permissions = IdentityAccessPermissions.DeserializeIdentityAccessPermissions(property.Value); continue; } if (options.Format != "W") @@ -132,35 +132,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.ToString()}'"); + builder.AppendLine($"'{TenantId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectId), out propertyOverride); if (Optional.IsDefined(ObjectId) || hasPropertyOverride) { - builder.Append(" objectId:"); + builder.Append(" objectId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ObjectId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ObjectId}'''"); } else { - builder.AppendLine($" '{ObjectId}'"); + builder.AppendLine($"'{ObjectId}'"); } } } @@ -168,28 +168,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationId), out propertyOverride); if (Optional.IsDefined(ApplicationId) || hasPropertyOverride) { - builder.Append(" applicationId:"); + builder.Append(" applicationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ApplicationId.Value.ToString()}'"); + builder.AppendLine($"'{ApplicationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permissions), out propertyOverride); if (Optional.IsDefined(Permissions) || hasPropertyOverride) { - builder.Append(" permissions:"); + builder.Append(" permissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Permissions, options, 2, false); + AppendChildObject(builder, Permissions, options, 2, false, " permissions: "); } } @@ -197,12 +197,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -223,13 +226,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyParameters.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyParameters.Serialization.cs index 10ce530ce2335..b060fbdcccb33 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyParameters.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyParameters.Serialization.cs @@ -115,7 +115,7 @@ internal static KeyVaultAccessPolicyParameters DeserializeKeyVaultAccessPolicyPa } if (property.NameEquals("properties"u8)) { - properties = KeyVaultAccessPolicyProperties.DeserializeKeyVaultAccessPolicyProperties(property.Value, options); + properties = KeyVaultAccessPolicyProperties.DeserializeKeyVaultAccessPolicyProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -165,21 +165,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -187,56 +187,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyProperties.Serialization.cs index d01a70782283d..899ae93fd01aa 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultAccessPolicyProperties.Serialization.cs @@ -84,7 +84,7 @@ internal static KeyVaultAccessPolicyProperties DeserializeKeyVaultAccessPolicyPr List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item, options)); + array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item)); } accessPolicies = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AccessPolicies.Any() || hasPropertyOverride) { - builder.Append(" accessPolicies:"); + builder.Append(" accessPolicies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AccessPolicies) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " accessPolicies: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultCreateOrUpdateContent.Serialization.cs index 68f7320594a7a..5e600e809b82c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultCreateOrUpdateContent.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultCreateOrUpdateContent.Serialization.cs @@ -107,7 +107,7 @@ internal static KeyVaultCreateOrUpdateContent DeserializeKeyVaultCreateOrUpdateC } if (property.NameEquals("properties"u8)) { - properties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value, options); + properties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultIPRule.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultIPRule.Serialization.cs index a1eb896831f33..831beac2d4394 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultIPRule.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultIPRule.Serialization.cs @@ -101,21 +101,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AddressRange), out propertyOverride); if (Optional.IsDefined(AddressRange) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AddressRange.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AddressRange}'''"); } else { - builder.AppendLine($" '{AddressRange}'"); + builder.AppendLine($"'{AddressRange}'"); } } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNameAvailabilityResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNameAvailabilityResult.Serialization.cs index 32bf7a1663eb9..cf8de822ce07c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNameAvailabilityResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNameAvailabilityResult.Serialization.cs @@ -134,50 +134,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameAvailable), out propertyOverride); if (Optional.IsDefined(NameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = NameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToSerialString()}'"); + builder.AppendLine($"'{Reason.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNetworkRuleSet.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNetworkRuleSet.Serialization.cs index a1b6bdd136b5c..9824e51c79b72 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNetworkRuleSet.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultNetworkRuleSet.Serialization.cs @@ -132,7 +132,7 @@ internal static KeyVaultNetworkRuleSet DeserializeKeyVaultNetworkRuleSet(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultIPRule.DeserializeKeyVaultIPRule(item, options)); + array.Add(KeyVaultIPRule.DeserializeKeyVaultIPRule(item)); } ipRules = array; continue; @@ -146,7 +146,7 @@ internal static KeyVaultNetworkRuleSet DeserializeKeyVaultNetworkRuleSet(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultVirtualNetworkRule.DeserializeKeyVaultVirtualNetworkRule(item, options)); + array.Add(KeyVaultVirtualNetworkRule.DeserializeKeyVaultVirtualNetworkRule(item)); } virtualNetworkRules = array; continue; @@ -174,28 +174,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Bypass), out propertyOverride); if (Optional.IsDefined(Bypass) || hasPropertyOverride) { - builder.Append(" bypass:"); + builder.Append(" bypass: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Bypass.Value.ToString()}'"); + builder.AppendLine($"'{Bypass.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAction), out propertyOverride); if (Optional.IsDefined(DefaultAction) || hasPropertyOverride) { - builder.Append(" defaultAction:"); + builder.Append(" defaultAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultAction.Value.ToString()}'"); + builder.AppendLine($"'{DefaultAction.Value.ToString()}'"); } } @@ -204,17 +204,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPRules.Any() || hasPropertyOverride) { - builder.Append(" ipRules:"); + builder.Append(" ipRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " ipRules: "); } builder.AppendLine(" ]"); } @@ -226,17 +226,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualNetworkRules.Any() || hasPropertyOverride) { - builder.Append(" virtualNetworkRules:"); + builder.Append(" virtualNetworkRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualNetworkRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " virtualNetworkRules: "); } builder.AppendLine(" ]"); } @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatch.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatch.Serialization.cs index ec6f0ef0807a9..d99db31f4a866 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatch.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatch.Serialization.cs @@ -106,7 +106,7 @@ internal static KeyVaultPatch DeserializeKeyVaultPatch(JsonElement element, Mode { continue; } - properties = KeyVaultPatchProperties.DeserializeKeyVaultPatchProperties(property.Value, options); + properties = KeyVaultPatchProperties.DeserializeKeyVaultPatchProperties(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatchProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatchProperties.Serialization.cs index f74ed81e413e6..5cb40355065c6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatchProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPatchProperties.Serialization.cs @@ -166,7 +166,7 @@ internal static KeyVaultPatchProperties DeserializeKeyVaultPatchProperties(JsonE { continue; } - sku = KeyVaultSku.DeserializeKeyVaultSku(property.Value, options); + sku = KeyVaultSku.DeserializeKeyVaultSku(property.Value); continue; } if (property.NameEquals("accessPolicies"u8)) @@ -178,7 +178,7 @@ internal static KeyVaultPatchProperties DeserializeKeyVaultPatchProperties(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item, options)); + array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item)); } accessPolicies = array; continue; @@ -261,7 +261,7 @@ internal static KeyVaultPatchProperties DeserializeKeyVaultPatchProperties(JsonE { continue; } - networkAcls = KeyVaultNetworkRuleSet.DeserializeKeyVaultNetworkRuleSet(property.Value, options); + networkAcls = KeyVaultNetworkRuleSet.DeserializeKeyVaultNetworkRuleSet(property.Value); continue; } if (property.NameEquals("publicNetworkAccess"u8)) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionItemData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionItemData.Serialization.cs index 3e96c0f4088f2..d01c5465e9633 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionItemData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionItemData.Serialization.cs @@ -143,7 +143,7 @@ internal static KeyVaultPrivateEndpointConnectionItemData DeserializeKeyVaultPri { continue; } - privateLinkServiceConnectionState = KeyVaultPrivateLinkServiceConnectionState.DeserializeKeyVaultPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = KeyVaultPrivateLinkServiceConnectionState.DeserializeKeyVaultPrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -203,14 +203,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } @@ -219,42 +219,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -263,12 +263,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -289,13 +292,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionListResult.Serialization.cs index fab5b6cea8976..824e5f703bfea 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateEndpointConnectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static KeyVaultPrivateEndpointConnectionListResult DeserializeKeyVaultP List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultPrivateEndpointConnectionData.DeserializeKeyVaultPrivateEndpointConnectionData(item, options)); + array.Add(KeyVaultPrivateEndpointConnectionData.DeserializeKeyVaultPrivateEndpointConnectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceData.Serialization.cs index c9300f735dcbb..17d23c511a3ee 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceData.Serialization.cs @@ -260,21 +260,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -282,14 +282,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -298,17 +298,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -316,12 +316,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -332,28 +332,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -362,21 +362,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -386,14 +386,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -421,14 +421,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -456,12 +456,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -482,13 +485,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceListResult.Serialization.cs index 9e61e8ec47c14..5f72ced221525 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkResourceListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static KeyVaultPrivateLinkResourceListResult DeserializeKeyVaultPrivate List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultPrivateLinkResourceData.DeserializeKeyVaultPrivateLinkResourceData(item, options)); + array.Add(KeyVaultPrivateLinkResourceData.DeserializeKeyVaultPrivateLinkResourceData(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkServiceConnectionState.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkServiceConnectionState.Serialization.cs index 68b2557e9a494..fc15fb3ed219e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultPrivateLinkServiceConnectionState.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -170,14 +170,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionsRequired.Value.ToString()}'"); + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultProperties.Serialization.cs index b052acd87a74e..6272e5b9e96a5 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultProperties.Serialization.cs @@ -184,7 +184,7 @@ internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement ele } if (property.NameEquals("sku"u8)) { - sku = KeyVaultSku.DeserializeKeyVaultSku(property.Value, options); + sku = KeyVaultSku.DeserializeKeyVaultSku(property.Value); continue; } if (property.NameEquals("accessPolicies"u8)) @@ -196,7 +196,7 @@ internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item, options)); + array.Add(KeyVaultAccessPolicy.DeserializeKeyVaultAccessPolicy(item)); } accessPolicies = array; continue; @@ -293,7 +293,7 @@ internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement ele { continue; } - networkAcls = KeyVaultNetworkRuleSet.DeserializeKeyVaultNetworkRuleSet(property.Value, options); + networkAcls = KeyVaultNetworkRuleSet.DeserializeKeyVaultNetworkRuleSet(property.Value); continue; } if (property.NameEquals("provisioningState"u8)) @@ -314,7 +314,7 @@ internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultPrivateEndpointConnectionItemData.DeserializeKeyVaultPrivateEndpointConnectionItemData(item, options)); + array.Add(KeyVaultPrivateEndpointConnectionItemData.DeserializeKeyVaultPrivateEndpointConnectionItemData(item)); } privateEndpointConnections = array; continue; @@ -347,28 +347,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.ToString()}'"); + builder.AppendLine($"'{TenantId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } @@ -377,17 +377,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AccessPolicies.Any() || hasPropertyOverride) { - builder.Append(" accessPolicies:"); + builder.Append(" accessPolicies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AccessPolicies) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " accessPolicies: "); } builder.AppendLine(" ]"); } @@ -397,35 +397,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VaultUri), out propertyOverride); if (Optional.IsDefined(VaultUri) || hasPropertyOverride) { - builder.Append(" vaultUri:"); + builder.Append(" vaultUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VaultUri.AbsoluteUri}'"); + builder.AppendLine($"'{VaultUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HsmPoolResourceId), out propertyOverride); if (Optional.IsDefined(HsmPoolResourceId) || hasPropertyOverride) { - builder.Append(" hsmPoolResourceId:"); + builder.Append(" hsmPoolResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HsmPoolResourceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HsmPoolResourceId}'''"); } else { - builder.AppendLine($" '{HsmPoolResourceId}'"); + builder.AppendLine($"'{HsmPoolResourceId}'"); } } } @@ -433,146 +433,146 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledForDeployment), out propertyOverride); if (Optional.IsDefined(EnabledForDeployment) || hasPropertyOverride) { - builder.Append(" enabledForDeployment:"); + builder.Append(" enabledForDeployment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnabledForDeployment.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledForDiskEncryption), out propertyOverride); if (Optional.IsDefined(EnabledForDiskEncryption) || hasPropertyOverride) { - builder.Append(" enabledForDiskEncryption:"); + builder.Append(" enabledForDiskEncryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnabledForDiskEncryption.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledForTemplateDeployment), out propertyOverride); if (Optional.IsDefined(EnabledForTemplateDeployment) || hasPropertyOverride) { - builder.Append(" enabledForTemplateDeployment:"); + builder.Append(" enabledForTemplateDeployment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnabledForTemplateDeployment.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableSoftDelete), out propertyOverride); if (Optional.IsDefined(EnableSoftDelete) || hasPropertyOverride) { - builder.Append(" enableSoftDelete:"); + builder.Append(" enableSoftDelete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableSoftDelete.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SoftDeleteRetentionInDays), out propertyOverride); if (Optional.IsDefined(SoftDeleteRetentionInDays) || hasPropertyOverride) { - builder.Append(" softDeleteRetentionInDays:"); + builder.Append(" softDeleteRetentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SoftDeleteRetentionInDays.Value}"); + builder.AppendLine($"{SoftDeleteRetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableRbacAuthorization), out propertyOverride); if (Optional.IsDefined(EnableRbacAuthorization) || hasPropertyOverride) { - builder.Append(" enableRbacAuthorization:"); + builder.Append(" enableRbacAuthorization: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableRbacAuthorization.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); if (Optional.IsDefined(CreateMode) || hasPropertyOverride) { - builder.Append(" createMode:"); + builder.Append(" createMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{CreateMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnablePurgeProtection), out propertyOverride); if (Optional.IsDefined(EnablePurgeProtection) || hasPropertyOverride) { - builder.Append(" enablePurgeProtection:"); + builder.Append(" enablePurgeProtection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnablePurgeProtection.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkRuleSet), out propertyOverride); if (Optional.IsDefined(NetworkRuleSet) || hasPropertyOverride) { - builder.Append(" networkAcls:"); + builder.Append(" networkAcls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, NetworkRuleSet, options, 2, false); + AppendChildObject(builder, NetworkRuleSet, options, 2, false, " networkAcls: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -581,17 +581,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -601,21 +601,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicNetworkAccess.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicNetworkAccess}'''"); } else { - builder.AppendLine($" '{PublicNetworkAccess}'"); + builder.AppendLine($"'{PublicNetworkAccess}'"); } } } @@ -624,12 +624,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -650,13 +653,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretCreateOrUpdateContent.Serialization.cs index a78ab9ab212a2..4c19105de01cf 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretCreateOrUpdateContent.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretCreateOrUpdateContent.Serialization.cs @@ -99,7 +99,7 @@ internal static KeyVaultSecretCreateOrUpdateContent DeserializeKeyVaultSecretCre } if (property.NameEquals("properties"u8)) { - properties = SecretProperties.DeserializeSecretProperties(property.Value, options); + properties = SecretProperties.DeserializeSecretProperties(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretPatch.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretPatch.Serialization.cs index 7863fecba2ad1..c7dfd48878228 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretPatch.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSecretPatch.Serialization.cs @@ -106,7 +106,7 @@ internal static KeyVaultSecretPatch DeserializeKeyVaultSecretPatch(JsonElement e { continue; } - properties = SecretPatchProperties.DeserializeSecretPatchProperties(property.Value, options); + properties = SecretPatchProperties.DeserializeSecretPatchProperties(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSku.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSku.Serialization.cs index 7ddb62c7c74e5..015eb8e7e3268 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSku.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultSku.Serialization.cs @@ -109,28 +109,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToSerialString()}'"); + builder.AppendLine($"'{Name.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Family.ToString()}'"); + builder.AppendLine($"'{Family.ToString()}'"); } } @@ -138,12 +138,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -164,13 +167,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultVirtualNetworkRule.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultVirtualNetworkRule.Serialization.cs index a0d057faccef7..4163798a9f0a0 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultVirtualNetworkRule.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyVaultVirtualNetworkRule.Serialization.cs @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -138,15 +138,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreMissingVnetServiceEndpoint), out propertyOverride); if (Optional.IsDefined(IgnoreMissingVnetServiceEndpoint) || hasPropertyOverride) { - builder.Append(" ignoreMissingVnetServiceEndpoint:"); + builder.Append(" ignoreMissingVnetServiceEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IgnoreMissingVnetServiceEndpoint.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMSecurityDomainProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMSecurityDomainProperties.Serialization.cs index f241065a69709..4af6c6c0d803f 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMSecurityDomainProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMSecurityDomainProperties.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActivationStatus), out propertyOverride); if (Optional.IsDefined(ActivationStatus) || hasPropertyOverride) { - builder.Append(" activationStatus:"); + builder.Append(" activationStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActivationStatus.Value.ToString()}'"); + builder.AppendLine($"'{ActivationStatus.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActivationStatusMessage), out propertyOverride); if (Optional.IsDefined(ActivationStatusMessage) || hasPropertyOverride) { - builder.Append(" activationStatusMessage:"); + builder.Append(" activationStatusMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActivationStatusMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActivationStatusMessage}'''"); } else { - builder.AppendLine($" '{ActivationStatusMessage}'"); + builder.AppendLine($"'{ActivationStatusMessage}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmGeoReplicatedRegion.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmGeoReplicatedRegion.Serialization.cs index 074df7c74b875..5da403e19d1b3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmGeoReplicatedRegion.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmGeoReplicatedRegion.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,29 +156,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrimary), out propertyOverride); if (Optional.IsDefined(IsPrimary) || hasPropertyOverride) { - builder.Append(" isPrimary:"); + builder.Append(" isPrimary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrimary.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmIPRule.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmIPRule.Serialization.cs index b128806377158..318fcd30443b4 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmIPRule.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmIPRule.Serialization.cs @@ -101,21 +101,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AddressRange), out propertyOverride); if (Optional.IsDefined(AddressRange) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AddressRange.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AddressRange}'''"); } else { - builder.AppendLine($" '{AddressRange}'"); + builder.AppendLine($"'{AddressRange}'"); } } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmListResult.Serialization.cs index aabd4f9780785..ca381572f69c1 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedHsmListResult DeserializeManagedHsmListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmData.DeserializeManagedHsmData(item, options)); + array.Add(ManagedHsmData.DeserializeManagedHsmData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNameAvailabilityResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNameAvailabilityResult.Serialization.cs index 725afcb436c9b..d86ba44fe0d9e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNameAvailabilityResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNameAvailabilityResult.Serialization.cs @@ -134,50 +134,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsNameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToString()}'"); + builder.AppendLine($"'{Reason.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNetworkRuleSet.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNetworkRuleSet.Serialization.cs index c4645615f9dd0..56e7bd29d76e9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNetworkRuleSet.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmNetworkRuleSet.Serialization.cs @@ -132,7 +132,7 @@ internal static ManagedHsmNetworkRuleSet DeserializeManagedHsmNetworkRuleSet(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmIPRule.DeserializeManagedHsmIPRule(item, options)); + array.Add(ManagedHsmIPRule.DeserializeManagedHsmIPRule(item)); } ipRules = array; continue; @@ -146,7 +146,7 @@ internal static ManagedHsmNetworkRuleSet DeserializeManagedHsmNetworkRuleSet(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmVirtualNetworkRule.DeserializeManagedHsmVirtualNetworkRule(item, options)); + array.Add(ManagedHsmVirtualNetworkRule.DeserializeManagedHsmVirtualNetworkRule(item)); } virtualNetworkRules = array; continue; @@ -174,28 +174,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Bypass), out propertyOverride); if (Optional.IsDefined(Bypass) || hasPropertyOverride) { - builder.Append(" bypass:"); + builder.Append(" bypass: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Bypass.Value.ToString()}'"); + builder.AppendLine($"'{Bypass.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAction), out propertyOverride); if (Optional.IsDefined(DefaultAction) || hasPropertyOverride) { - builder.Append(" defaultAction:"); + builder.Append(" defaultAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultAction.Value.ToString()}'"); + builder.AppendLine($"'{DefaultAction.Value.ToString()}'"); } } @@ -204,17 +204,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPRules.Any() || hasPropertyOverride) { - builder.Append(" ipRules:"); + builder.Append(" ipRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " ipRules: "); } builder.AppendLine(" ]"); } @@ -226,17 +226,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualNetworkRules.Any() || hasPropertyOverride) { - builder.Append(" virtualNetworkRules:"); + builder.Append(" virtualNetworkRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualNetworkRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " virtualNetworkRules: "); } builder.AppendLine(" ]"); } @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionItemData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionItemData.Serialization.cs index 12bc4182ac9ef..54e28b03561fc 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionItemData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionItemData.Serialization.cs @@ -147,7 +147,7 @@ internal static ManagedHsmPrivateEndpointConnectionItemData DeserializeManagedHs { continue; } - privateLinkServiceConnectionState = ManagedHsmPrivateLinkServiceConnectionState.DeserializeManagedHsmPrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = ManagedHsmPrivateLinkServiceConnectionState.DeserializeManagedHsmPrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -185,28 +185,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } @@ -215,42 +215,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -259,12 +259,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -285,13 +288,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionsListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionsListResult.Serialization.cs index aa648ae64b479..9c954c28e7aae 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionsListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateEndpointConnectionsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedHsmPrivateEndpointConnectionsListResult DeserializeManage List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmPrivateEndpointConnectionData.DeserializeManagedHsmPrivateEndpointConnectionData(item, options)); + array.Add(ManagedHsmPrivateEndpointConnectionData.DeserializeManagedHsmPrivateEndpointConnectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs index a864f0ddc4917..a9b1f73cd898a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs @@ -154,7 +154,7 @@ internal static ManagedHsmPrivateLinkResourceData DeserializeManagedHsmPrivateLi { continue; } - sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); + sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -290,14 +290,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -306,17 +306,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -324,12 +324,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -340,42 +340,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -384,21 +384,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -408,14 +408,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -443,14 +443,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -478,12 +478,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -504,13 +507,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceListResult.Serialization.cs index ef81f9a040923..0407358c9c12a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static ManagedHsmPrivateLinkResourceListResult DeserializeManagedHsmPri List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmPrivateLinkResourceData.DeserializeManagedHsmPrivateLinkResourceData(item, options)); + array.Add(ManagedHsmPrivateLinkResourceData.DeserializeManagedHsmPrivateLinkResourceData(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkServiceConnectionState.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkServiceConnectionState.Serialization.cs index a0ff787a95981..49feeedb76cc9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkServiceConnectionState.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -170,14 +170,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionsRequired.Value.ToString()}'"); + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmProperties.Serialization.cs index 33f5fdd4450a7..325668fdb1278 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmProperties.Serialization.cs @@ -264,7 +264,7 @@ internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement { continue; } - networkAcls = ManagedHsmNetworkRuleSet.DeserializeManagedHsmNetworkRuleSet(property.Value, options); + networkAcls = ManagedHsmNetworkRuleSet.DeserializeManagedHsmNetworkRuleSet(property.Value); continue; } if (property.NameEquals("regions"u8)) @@ -276,7 +276,7 @@ internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmGeoReplicatedRegion.DeserializeManagedHsmGeoReplicatedRegion(item, options)); + array.Add(ManagedHsmGeoReplicatedRegion.DeserializeManagedHsmGeoReplicatedRegion(item)); } regions = array; continue; @@ -290,7 +290,7 @@ internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmPrivateEndpointConnectionItemData.DeserializeManagedHsmPrivateEndpointConnectionItemData(item, options)); + array.Add(ManagedHsmPrivateEndpointConnectionItemData.DeserializeManagedHsmPrivateEndpointConnectionItemData(item)); } privateEndpointConnections = array; continue; @@ -319,7 +319,7 @@ internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement { continue; } - securityDomainProperties = ManagedHSMSecurityDomainProperties.DeserializeManagedHSMSecurityDomainProperties(property.Value, options); + securityDomainProperties = ManagedHSMSecurityDomainProperties.DeserializeManagedHSMSecurityDomainProperties(property.Value); continue; } if (options.Format != "W") @@ -345,14 +345,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -361,14 +361,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (InitialAdminObjectIds.Any() || hasPropertyOverride) { - builder.Append(" initialAdminObjectIds:"); + builder.Append(" initialAdminObjectIds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in InitialAdminObjectIds) { if (item == null) @@ -394,93 +394,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HsmUri), out propertyOverride); if (Optional.IsDefined(HsmUri) || hasPropertyOverride) { - builder.Append(" hsmUri:"); + builder.Append(" hsmUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{HsmUri.AbsoluteUri}'"); + builder.AppendLine($"'{HsmUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableSoftDelete), out propertyOverride); if (Optional.IsDefined(EnableSoftDelete) || hasPropertyOverride) { - builder.Append(" enableSoftDelete:"); + builder.Append(" enableSoftDelete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableSoftDelete.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SoftDeleteRetentionInDays), out propertyOverride); if (Optional.IsDefined(SoftDeleteRetentionInDays) || hasPropertyOverride) { - builder.Append(" softDeleteRetentionInDays:"); + builder.Append(" softDeleteRetentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SoftDeleteRetentionInDays.Value}"); + builder.AppendLine($"{SoftDeleteRetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnablePurgeProtection), out propertyOverride); if (Optional.IsDefined(EnablePurgeProtection) || hasPropertyOverride) { - builder.Append(" enablePurgeProtection:"); + builder.Append(" enablePurgeProtection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnablePurgeProtection.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); if (Optional.IsDefined(CreateMode) || hasPropertyOverride) { - builder.Append(" createMode:"); + builder.Append(" createMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{CreateMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusMessage), out propertyOverride); if (Optional.IsDefined(StatusMessage) || hasPropertyOverride) { - builder.Append(" statusMessage:"); + builder.Append(" statusMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StatusMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StatusMessage}'''"); } else { - builder.AppendLine($" '{StatusMessage}'"); + builder.AppendLine($"'{StatusMessage}'"); } } } @@ -488,28 +488,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkRuleSet), out propertyOverride); if (Optional.IsDefined(NetworkRuleSet) || hasPropertyOverride) { - builder.Append(" networkAcls:"); + builder.Append(" networkAcls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, NetworkRuleSet, options, 2, false); + AppendChildObject(builder, NetworkRuleSet, options, 2, false, " networkAcls: "); } } @@ -518,17 +518,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Regions.Any() || hasPropertyOverride) { - builder.Append(" regions:"); + builder.Append(" regions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Regions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " regions: "); } builder.AppendLine(" ]"); } @@ -540,17 +540,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -560,43 +560,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicNetworkAccess.Value.ToString()}'"); + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduledPurgeOn), out propertyOverride); if (Optional.IsDefined(ScheduledPurgeOn) || hasPropertyOverride) { - builder.Append(" scheduledPurgeDate:"); + builder.Append(" scheduledPurgeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ScheduledPurgeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecurityDomainProperties), out propertyOverride); if (Optional.IsDefined(SecurityDomainProperties) || hasPropertyOverride) { - builder.Append(" securityDomainProperties:"); + builder.Append(" securityDomainProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SecurityDomainProperties, options, 2, false); + AppendChildObject(builder, SecurityDomainProperties, options, 2, false, " securityDomainProperties: "); } } @@ -604,12 +604,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -630,13 +633,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRegionsListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRegionsListResult.Serialization.cs index da4a599c87da2..6f266daab1fdd 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRegionsListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRegionsListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ManagedHsmRegionsListResult DeserializeManagedHsmRegionsListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedHsmGeoReplicatedRegion.DeserializeManagedHsmGeoReplicatedRegion(item, options)); + array.Add(ManagedHsmGeoReplicatedRegion.DeserializeManagedHsmGeoReplicatedRegion(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmSku.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmSku.Serialization.cs index 32755c86347f8..549d5e8124e34 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmSku.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmSku.Serialization.cs @@ -109,28 +109,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToSerialString()}'"); + builder.AppendLine($"'{Name.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Family.ToString()}'"); + builder.AppendLine($"'{Family.ToString()}'"); } } @@ -138,12 +138,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -164,13 +167,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmVirtualNetworkRule.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmVirtualNetworkRule.Serialization.cs index 0aa91a226bc71..0d2dd5c4a0f3d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmVirtualNetworkRule.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmVirtualNetworkRule.Serialization.cs @@ -101,14 +101,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetId), out propertyOverride); if (Optional.IsDefined(SubnetId) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetId.ToString()}'"); + builder.AppendLine($"'{SubnetId.ToString()}'"); } } @@ -116,12 +116,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -142,13 +145,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretAttributes.Serialization.cs index 4e4ee9443ed2d..0c8ccb42b6a49 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretAttributes.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretAttributes.Serialization.cs @@ -168,75 +168,75 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); if (Optional.IsDefined(Enabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); if (Optional.IsDefined(NotBefore) || hasPropertyOverride) { - builder.Append(" nbf:"); + builder.Append(" nbf: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotBefore.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); if (Optional.IsDefined(Expires) || hasPropertyOverride) { - builder.Append(" exp:"); + builder.Append(" exp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Expires.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); if (Optional.IsDefined(Created) || hasPropertyOverride) { - builder.Append(" created:"); + builder.Append(" created: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Created.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); if (Optional.IsDefined(Updated) || hasPropertyOverride) { - builder.Append(" updated:"); + builder.Append(" updated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Updated.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretBaseAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretBaseAttributes.Serialization.cs index 280e41eebfdf3..2161eb32f8fa2 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretBaseAttributes.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretBaseAttributes.Serialization.cs @@ -168,75 +168,75 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); if (Optional.IsDefined(Enabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); if (Optional.IsDefined(NotBefore) || hasPropertyOverride) { - builder.Append(" nbf:"); + builder.Append(" nbf: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotBefore.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); if (Optional.IsDefined(Expires) || hasPropertyOverride) { - builder.Append(" exp:"); + builder.Append(" exp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Expires.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); if (Optional.IsDefined(Created) || hasPropertyOverride) { - builder.Append(" created:"); + builder.Append(" created: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Created.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); if (Optional.IsDefined(Updated) || hasPropertyOverride) { - builder.Append(" updated:"); + builder.Append(" updated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Updated.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretListResult.Serialization.cs index e37c56487a6bc..49e2cd0b8f1e1 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SecretListResult DeserializeSecretListResult(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultSecretData.DeserializeKeyVaultSecretData(item, options)); + array.Add(KeyVaultSecretData.DeserializeKeyVaultSecretData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretPatchProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretPatchProperties.Serialization.cs index 2600e5e03b3df..2d437678fcecb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretPatchProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretPatchProperties.Serialization.cs @@ -102,7 +102,7 @@ internal static SecretPatchProperties DeserializeSecretPatchProperties(JsonEleme { continue; } - attributes = SecretAttributes.DeserializeSecretAttributes(property.Value, options); + attributes = SecretAttributes.DeserializeSecretAttributes(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretProperties.Serialization.cs index b4828a5b3f2d4..a0e7d8d304255 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/SecretProperties.Serialization.cs @@ -116,7 +116,7 @@ internal static SecretProperties DeserializeSecretProperties(JsonElement element { continue; } - attributes = SecretAttributes.DeserializeSecretAttributes(property.Value, options); + attributes = SecretAttributes.DeserializeSecretAttributes(property.Value); continue; } if (property.NameEquals("secretUri"u8)) @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); if (Optional.IsDefined(ContentType) || hasPropertyOverride) { - builder.Append(" contentType:"); + builder.Append(" contentType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentType}'''"); } else { - builder.AppendLine($" '{ContentType}'"); + builder.AppendLine($"'{ContentType}'"); } } } @@ -200,49 +200,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); if (Optional.IsDefined(Attributes) || hasPropertyOverride) { - builder.Append(" attributes:"); + builder.Append(" attributes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Attributes, options, 2, false); + AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretUri), out propertyOverride); if (Optional.IsDefined(SecretUri) || hasPropertyOverride) { - builder.Append(" secretUri:"); + builder.Append(" secretUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SecretUri.AbsoluteUri}'"); + builder.AppendLine($"'{SecretUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretUriWithVersion), out propertyOverride); if (Optional.IsDefined(SecretUriWithVersion) || hasPropertyOverride) { - builder.Append(" secretUriWithVersion:"); + builder.Append(" secretUriWithVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecretUriWithVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecretUriWithVersion}'''"); } else { - builder.AppendLine($" '{SecretUriWithVersion}'"); + builder.AppendLine($"'{SecretUriWithVersion}'"); } } } @@ -251,12 +251,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -277,13 +280,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultListResult.Serialization.cs index 843d0945b73db..9aa78c3dcfa9a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static VaultListResult DeserializeVaultListResult(JsonElement element, List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyVaultData.DeserializeKeyVaultData(item, options)); + array.Add(KeyVaultData.DeserializeKeyVaultData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs index 838780aa3d5f4..957eb20305c4a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Publisher), out propertyOverride); if (Optional.IsDefined(Publisher) || hasPropertyOverride) { - builder.Append(" publisher:"); + builder.Append(" publisher: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Publisher.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Publisher}'''"); } else { - builder.AppendLine($" '{Publisher}'"); + builder.AppendLine($"'{Publisher}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -185,21 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PromotionCode), out propertyOverride); if (Optional.IsDefined(PromotionCode) || hasPropertyOverride) { - builder.Append(" promotionCode:"); + builder.Append(" promotionCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PromotionCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PromotionCode}'''"); } else { - builder.AppendLine($" '{PromotionCode}'"); + builder.AppendLine($"'{PromotionCode}'"); } } } @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -230,12 +230,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -256,13 +259,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs index 9a69205e03e1b..34999df004048 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs @@ -133,21 +133,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -155,35 +155,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Tier.Value.ToSerialString()}'"); + builder.AppendLine($"'{Tier.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -191,21 +191,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -213,14 +213,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Capacity.Value}"); + builder.AppendLine($"{Capacity.Value}"); } } @@ -228,12 +228,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -254,13 +257,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs index 19826b2cedc18..834114e857ae2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs @@ -82,7 +82,7 @@ internal static EncryptionProperties DeserializeEncryptionProperties(JsonElement { continue; } - keyVaultProperties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value, options); + keyVaultProperties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value); continue; } } @@ -103,28 +103,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) { - builder.Append(" keyVaultProperties:"); + builder.Append(" keyVaultProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyVaultProperties, options, 2, false); + AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); } } @@ -132,12 +132,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -158,13 +161,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs index 7c32e8d772281..5f79b85b871eb 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs @@ -95,21 +95,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyIdentifier), out propertyOverride); if (Optional.IsDefined(KeyIdentifier) || hasPropertyOverride) { - builder.Append(" keyIdentifier:"); + builder.Append(" keyIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyIdentifier}'''"); } else { - builder.AppendLine($" '{KeyIdentifier}'"); + builder.AppendLine($"'{KeyIdentifier}'"); } } } @@ -117,21 +117,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Identity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Identity}'''"); } else { - builder.AppendLine($" '{Identity}'"); + builder.AppendLine($"'{Identity}'"); } } } @@ -140,12 +140,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -166,13 +169,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs index 3190f8b588f56..d21af57c3c48f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs @@ -197,21 +197,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -219,35 +219,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -255,44 +255,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PercentComplete.Value.ToString()}'"); + builder.AppendLine($"'{PercentComplete.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -301,17 +301,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Operations.Any() || hasPropertyOverride) { - builder.Append(" operations:"); + builder.Append(" operations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Operations) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " operations: "); } builder.AppendLine(" ]"); } @@ -321,14 +321,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs index 3d092021beb63..7c56cef78b41b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs @@ -111,28 +111,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -140,12 +140,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -166,13 +169,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs index 633abaa47e411..f319f10b08143 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs @@ -155,21 +155,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedBy), out propertyOverride); if (Optional.IsDefined(CreatedBy) || hasPropertyOverride) { - builder.Append(" createdBy:"); + builder.Append(" createdBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CreatedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CreatedBy}'''"); } else { - builder.AppendLine($" '{CreatedBy}'"); + builder.AppendLine($"'{CreatedBy}'"); } } } @@ -177,50 +177,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedByType), out propertyOverride); if (Optional.IsDefined(CreatedByType) || hasPropertyOverride) { - builder.Append(" createdByType:"); + builder.Append(" createdByType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreatedByType.Value.ToString()}'"); + builder.AppendLine($"'{CreatedByType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdAt:"); + builder.Append(" createdAt: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedBy), out propertyOverride); if (Optional.IsDefined(LastModifiedBy) || hasPropertyOverride) { - builder.Append(" lastModifiedBy:"); + builder.Append(" lastModifiedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastModifiedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastModifiedBy}'''"); } else { - builder.AppendLine($" '{LastModifiedBy}'"); + builder.AppendLine($"'{LastModifiedBy}'"); } } } @@ -228,29 +228,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedByType), out propertyOverride); if (Optional.IsDefined(LastModifiedByType) || hasPropertyOverride) { - builder.Append(" lastModifiedByType:"); + builder.Append(" lastModifiedByType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LastModifiedByType.Value.ToString()}'"); + builder.AppendLine($"'{LastModifiedByType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedAt:"); + builder.Append(" lastModifiedAt: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -258,12 +258,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -284,13 +287,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs index d5aae59fb50c9..20abbd9836e87 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs @@ -103,28 +103,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ClientId.Value.ToString()}'"); + builder.AppendLine($"'{ClientId.Value.ToString()}'"); } } @@ -132,12 +132,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -158,13 +161,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs index 298ece5788c3f..b0974a0d54280 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs @@ -189,7 +189,7 @@ internal static ManagementGroupData DeserializeManagementGroupData(JsonElement e { continue; } - details = ManagementGroupInfo.DeserializeManagementGroupInfo(property0.Value, options); + details = ManagementGroupInfo.DeserializeManagementGroupInfo(property0.Value); continue; } if (property0.NameEquals("children"u8)) @@ -202,7 +202,7 @@ internal static ManagementGroupData DeserializeManagementGroupData(JsonElement e List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagementGroupChildInfo.DeserializeManagementGroupChildInfo(item, options)); + array.Add(ManagementGroupChildInfo.DeserializeManagementGroupChildInfo(item)); } children = array; continue; @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -255,28 +255,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -285,35 +285,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -321,14 +321,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); if (Optional.IsDefined(Details) || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Details, options, 4, false); + AppendChildObject(builder, Details, options, 4, false, " details: "); } } @@ -337,17 +337,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Children.Any() || hasPropertyOverride) { - builder.Append(" children:"); + builder.Append(" children: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Children) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " children: "); } builder.AppendLine(" ]"); } @@ -359,12 +359,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -385,13 +388,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs index 9e369e63337c6..715cc79e21477 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs @@ -121,7 +121,7 @@ internal static CreateManagementGroupDetails DeserializeCreateManagementGroupDet { continue; } - parent = ManagementGroupParentCreateOptions.DeserializeManagementGroupParentCreateOptions(property.Value, options); + parent = ManagementGroupParentCreateOptions.DeserializeManagementGroupParentCreateOptions(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs index 03d144200d0d7..9d32406a3d057 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs @@ -174,7 +174,7 @@ internal static DescendantData DeserializeDescendantData(JsonElement element, Mo parent = null; continue; } - parent = DescendantParentGroupInfo.DeserializeDescendantParentGroupInfo(property0.Value, options); + parent = DescendantParentGroupInfo.DeserializeDescendantParentGroupInfo(property0.Value); continue; } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,28 +225,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -255,21 +255,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -277,14 +277,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parent), out propertyOverride); if (Optional.IsDefined(Parent) || hasPropertyOverride) { - builder.Append(" parent:"); + builder.Append(" parent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Parent, options, 4, false); + AppendChildObject(builder, Parent, options, 4, false, " parent: "); } } @@ -293,12 +293,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -319,13 +322,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs index 262704b764fe7..e3aca48e7b016 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static DescendantListResult DeserializeDescendantListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DescendantData.DeserializeDescendantData(item, options)); + array.Add(DescendantData.DeserializeDescendantData(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs index faa9be7679d3a..3675b85b8a9dc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs index 6c1405b2fdd11..7658c54bc27f0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs @@ -401,21 +401,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -423,28 +423,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -453,35 +453,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -489,84 +489,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parent), out propertyOverride); if (Optional.IsDefined(Parent) || hasPropertyOverride) { - builder.Append(" parent:"); + builder.Append(" parent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Parent, options, 4, false); + AppendChildObject(builder, Parent, options, 4, false, " parent: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permissions), out propertyOverride); if (Optional.IsDefined(Permissions) || hasPropertyOverride) { - builder.Append(" permissions:"); + builder.Append(" permissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Permissions.Value.ToSerialString()}'"); + builder.AppendLine($"'{Permissions.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InheritedPermissions), out propertyOverride); if (Optional.IsDefined(InheritedPermissions) || hasPropertyOverride) { - builder.Append(" inheritedPermissions:"); + builder.Append(" inheritedPermissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InheritedPermissions.Value.ToSerialString()}'"); + builder.AppendLine($"'{InheritedPermissions.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfDescendants), out propertyOverride); if (Optional.IsDefined(NumberOfDescendants) || hasPropertyOverride) { - builder.Append(" numberOfDescendants:"); + builder.Append(" numberOfDescendants: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfDescendants.Value}"); + builder.AppendLine($"{NumberOfDescendants.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfChildren), out propertyOverride); if (Optional.IsDefined(NumberOfChildren) || hasPropertyOverride) { - builder.Append(" numberOfChildren:"); + builder.Append(" numberOfChildren: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfChildren.Value}"); + builder.AppendLine($"{NumberOfChildren.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfChildGroups), out propertyOverride); if (Optional.IsDefined(NumberOfChildGroups) || hasPropertyOverride) { - builder.Append(" numberOfChildGroups:"); + builder.Append(" numberOfChildGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfChildGroups.Value}"); + builder.AppendLine($"{NumberOfChildGroups.Value}"); } } @@ -575,14 +575,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ParentDisplayNameChain.Any() || hasPropertyOverride) { - builder.Append(" parentDisplayNameChain:"); + builder.Append(" parentDisplayNameChain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ParentDisplayNameChain) { if (item == null) @@ -610,14 +610,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ParentNameChain.Any() || hasPropertyOverride) { - builder.Append(" parentNameChain:"); + builder.Append(" parentNameChain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ParentNameChain) { if (item == null) @@ -645,12 +645,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -671,13 +674,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs index 5acc0e2227101..7cf363517989f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs @@ -103,7 +103,7 @@ internal static EntityListResult DeserializeEntityListResult(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(EntityData.DeserializeEntityData(item, options)); + array.Add(EntityData.DeserializeEntityData(item)); } value = array; continue; @@ -147,17 +147,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -167,35 +167,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -204,12 +204,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -230,13 +233,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs index 59da0f88f9d74..009707079c28d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs @@ -139,7 +139,7 @@ internal static ManagementGroupChildInfo DeserializeManagementGroupChildInfo(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeManagementGroupChildInfo(item, options)); + array.Add(DeserializeManagementGroupChildInfo(item)); } children = array; continue; @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -189,21 +189,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -235,17 +235,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Children.Any() || hasPropertyOverride) { - builder.Append(" children:"); + builder.Append(" children: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Children) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " children: "); } builder.AppendLine(" ]"); } @@ -256,12 +256,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -282,13 +285,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs index cf701a83e167e..996d9d52f1c5d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs @@ -136,7 +136,7 @@ internal static ManagementGroupChildOptions DeserializeManagementGroupChildOptio List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeManagementGroupChildOptions(item, options)); + array.Add(DeserializeManagementGroupChildOptions(item)); } children = array; continue; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs index 08a852b730d11..3845938637721 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs @@ -185,7 +185,7 @@ internal static ManagementGroupCreateOrUpdateContent DeserializeManagementGroupC { continue; } - details = CreateManagementGroupDetails.DeserializeCreateManagementGroupDetails(property0.Value, options); + details = CreateManagementGroupDetails.DeserializeCreateManagementGroupDetails(property0.Value); continue; } if (property0.NameEquals("children"u8)) @@ -198,7 +198,7 @@ internal static ManagementGroupCreateOrUpdateContent DeserializeManagementGroupC List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagementGroupChildOptions.DeserializeManagementGroupChildOptions(item, options)); + array.Add(ManagementGroupChildOptions.DeserializeManagementGroupChildOptions(item)); } children = array; continue; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs index 6fe9188eea456..0a3ece80aeb98 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs @@ -178,7 +178,7 @@ internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement e { continue; } - parent = ParentManagementGroupInfo.DeserializeParentManagementGroupInfo(property.Value, options); + parent = ParentManagementGroupInfo.DeserializeParentManagementGroupInfo(property.Value); continue; } if (property.NameEquals("path"u8)) @@ -191,7 +191,7 @@ internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item, options)); + array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item)); } path = array; continue; @@ -221,7 +221,7 @@ internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item, options)); + array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item)); } managementGroupAncestorsChain = array; continue; @@ -249,50 +249,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Version.Value}"); + builder.AppendLine($"{Version.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedOn), out propertyOverride); if (Optional.IsDefined(UpdatedOn) || hasPropertyOverride) { - builder.Append(" updatedTime:"); + builder.Append(" updatedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(UpdatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedBy), out propertyOverride); if (Optional.IsDefined(UpdatedBy) || hasPropertyOverride) { - builder.Append(" updatedBy:"); + builder.Append(" updatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UpdatedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UpdatedBy}'''"); } else { - builder.AppendLine($" '{UpdatedBy}'"); + builder.AppendLine($"'{UpdatedBy}'"); } } } @@ -300,14 +300,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parent), out propertyOverride); if (Optional.IsDefined(Parent) || hasPropertyOverride) { - builder.Append(" parent:"); + builder.Append(" parent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Parent, options, 2, false); + AppendChildObject(builder, Parent, options, 2, false, " parent: "); } } @@ -316,17 +316,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Path.Any() || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Path) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " path: "); } builder.AppendLine(" ]"); } @@ -338,14 +338,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagementGroupAncestors.Any() || hasPropertyOverride) { - builder.Append(" managementGroupAncestors:"); + builder.Append(" managementGroupAncestors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagementGroupAncestors) { if (item == null) @@ -373,17 +373,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagementGroupAncestorChain.Any() || hasPropertyOverride) { - builder.Append(" managementGroupAncestorsChain:"); + builder.Append(" managementGroupAncestorsChain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagementGroupAncestorChain) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " managementGroupAncestorsChain: "); } builder.AppendLine(" ]"); } @@ -394,12 +394,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -420,13 +423,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs index afbbd192670b1..a61dd8b331d04 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagementGroupListResult DeserializeManagementGroupListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementGroupData.DeserializeManagementGroupData(item, options)); + array.Add(ManagementGroupData.DeserializeManagementGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" @nextLink:"); + builder.Append(" @nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs index 991631416a816..98dc2183d97c7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs @@ -134,50 +134,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameAvailable), out propertyOverride); if (Optional.IsDefined(NameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = NameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToSerialString()}'"); + builder.AppendLine($"'{Reason.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs index ee2d624098f2c..ef8f737de8ef9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs index 1c236b72f7c0a..02e9d28424aba 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs index 8a2be47596980..745e03d4a5e3a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs @@ -251,7 +251,7 @@ internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonEle List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(Models.ResourceTypeAliases.DeserializeResourceTypeAliases(item, options)); + array.Add(Models.ResourceTypeAliases.DeserializeResourceTypeAliases(item)); } resourceTypeAliases = array; continue; @@ -265,7 +265,7 @@ internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonEle List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(DataPolicyManifestEffect.DeserializeDataPolicyManifestEffect(item, options)); + array.Add(DataPolicyManifestEffect.DeserializeDataPolicyManifestEffect(item)); } effects = array; continue; @@ -316,7 +316,7 @@ internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonEle List array = new List(); foreach (var item in property1.Value.EnumerateArray()) { - array.Add(DataManifestCustomResourceFunctionDefinition.DeserializeDataManifestCustomResourceFunctionDefinition(item, options)); + array.Add(DataManifestCustomResourceFunctionDefinition.DeserializeDataManifestCustomResourceFunctionDefinition(item)); } custom = array; continue; @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -372,28 +372,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -404,14 +404,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Namespaces.Any() || hasPropertyOverride) { - builder.Append(" namespaces:"); + builder.Append(" namespaces: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Namespaces) { if (item == null) @@ -437,21 +437,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyMode), out propertyOverride); if (Optional.IsDefined(PolicyMode) || hasPropertyOverride) { - builder.Append(" policyMode:"); + builder.Append(" policyMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyMode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyMode}'''"); } else { - builder.AppendLine($" '{PolicyMode}'"); + builder.AppendLine($"'{PolicyMode}'"); } } } @@ -459,15 +459,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsBuiltInOnly), out propertyOverride); if (Optional.IsDefined(IsBuiltInOnly) || hasPropertyOverride) { - builder.Append(" isBuiltInOnly:"); + builder.Append(" isBuiltInOnly: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsBuiltInOnly.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -476,17 +476,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResourceTypeAliases.Any() || hasPropertyOverride) { - builder.Append(" resourceTypeAliases:"); + builder.Append(" resourceTypeAliases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResourceTypeAliases) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " resourceTypeAliases: "); } builder.AppendLine(" ]"); } @@ -498,17 +498,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Effects.Any() || hasPropertyOverride) { - builder.Append(" effects:"); + builder.Append(" effects: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Effects) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " effects: "); } builder.AppendLine(" ]"); } @@ -520,14 +520,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FieldValues.Any() || hasPropertyOverride) { - builder.Append(" fieldValues:"); + builder.Append(" fieldValues: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in FieldValues) { if (item == null) @@ -557,14 +557,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Standard.Any() || hasPropertyOverride) { - builder.Append(" standard:"); + builder.Append(" standard: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Standard) { if (item == null) @@ -592,17 +592,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CustomDefinitions.Any() || hasPropertyOverride) { - builder.Append(" custom:"); + builder.Append(" custom: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CustomDefinitions) { - AppendChildObject(builder, item, options, 8, true); + AppendChildObject(builder, item, options, 8, true, " custom: "); } builder.AppendLine(" ]"); } @@ -615,12 +615,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -641,13 +644,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs index 57f557d052430..987de22061bd2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs @@ -108,7 +108,7 @@ internal static FeatureData DeserializeFeatureData(JsonElement element, ModelRea { continue; } - properties = FeatureProperties.DeserializeFeatureProperties(property.Value, options); + properties = FeatureProperties.DeserializeFeatureProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,42 +180,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs index cff4a13af1c24..084613f4cf360 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs @@ -213,7 +213,7 @@ internal static GenericResourceData DeserializeGenericResourceData(JsonElement e { continue; } - sku = ResourcesSku.DeserializeResourcesSku(property.Value, options); + sku = ResourcesSku.DeserializeResourcesSku(property.Value); continue; } if (property.NameEquals("identity"u8)) @@ -323,21 +323,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -345,14 +345,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -361,17 +361,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -379,12 +379,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -395,49 +395,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Plan), out propertyOverride); if (Optional.IsDefined(Plan) || hasPropertyOverride) { - builder.Append(" plan:"); + builder.Append(" plan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Plan, options, 2, false); + AppendChildObject(builder, Plan, options, 2, false, " plan: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Properties.ToString()}'"); + builder.AppendLine($"'{Properties.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -445,21 +445,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -467,79 +467,79 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdTime:"); + builder.Append(" createdTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangedOn), out propertyOverride); if (Optional.IsDefined(ChangedOn) || hasPropertyOverride) { - builder.Append(" changedTime:"); + builder.Append(" changedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ChangedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -547,42 +547,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -590,12 +590,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -616,13 +619,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs index 6d21a4f241cc6..0d3b0f4455dda 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs @@ -172,7 +172,7 @@ internal static ManagementLockData DeserializeManagementLockData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagementLockOwner.DeserializeManagementLockOwner(item, options)); + array.Add(ManagementLockOwner.DeserializeManagementLockOwner(item)); } owners = array; continue; @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,28 +225,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -255,35 +255,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.ToString()}'"); + builder.AppendLine($"'{Level.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Notes), out propertyOverride); if (Optional.IsDefined(Notes) || hasPropertyOverride) { - builder.Append(" notes:"); + builder.Append(" notes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Notes.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Notes}'''"); } else { - builder.AppendLine($" '{Notes}'"); + builder.AppendLine($"'{Notes}'"); } } } @@ -293,17 +293,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Owners.Any() || hasPropertyOverride) { - builder.Append(" owners:"); + builder.Append(" owners: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Owners) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " owners: "); } builder.AppendLine(" ]"); } @@ -315,12 +315,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -341,13 +344,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs index 4f4d5928ff1c8..d68550dea6f52 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProfileVersion), out propertyOverride); if (Optional.IsDefined(ProfileVersion) || hasPropertyOverride) { - builder.Append(" profileVersion:"); + builder.Append(" profileVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProfileVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProfileVersion}'''"); } else { - builder.AppendLine($" '{ProfileVersion}'"); + builder.AppendLine($"'{ProfileVersion}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiVersion), out propertyOverride); if (Optional.IsDefined(ApiVersion) || hasPropertyOverride) { - builder.Append(" apiVersion:"); + builder.Append(" apiVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApiVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApiVersion}'''"); } else { - builder.AppendLine($" '{ApiVersion}'"); + builder.AppendLine($"'{ApiVersion}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs index 360a7f597b254..751d3a5d3d00e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs @@ -164,7 +164,7 @@ internal static ArmPolicyParameter DeserializeArmPolicyParameter(JsonElement ele { continue; } - metadata = ParameterDefinitionsValueMetadata.DeserializeParameterDefinitionsValueMetadata(property.Value, options); + metadata = ParameterDefinitionsValueMetadata.DeserializeParameterDefinitionsValueMetadata(property.Value); continue; } if (options.Format != "W") @@ -192,14 +192,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedValues.Any() || hasPropertyOverride) { - builder.Append(" allowedValues:"); + builder.Append(" allowedValues: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedValues) { if (item == null) @@ -217,28 +217,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultValue), out propertyOverride); if (Optional.IsDefined(DefaultValue) || hasPropertyOverride) { - builder.Append(" defaultValue:"); + builder.Append(" defaultValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultValue.ToString()}'"); + builder.AppendLine($"'{DefaultValue.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Metadata, options, 2, false); + AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -246,12 +246,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -272,13 +275,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs index 4c82b768857ab..3f2737fac80e4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs @@ -115,14 +115,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.ToString()}'"); + builder.AppendLine($"'{Value.ToString()}'"); } } @@ -130,12 +130,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -156,13 +159,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs index 8de1c23b2b6bc..dc0bc406714bc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogicalZone), out propertyOverride); if (Optional.IsDefined(LogicalZone) || hasPropertyOverride) { - builder.Append(" logicalZone:"); + builder.Append(" logicalZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LogicalZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LogicalZone}'''"); } else { - builder.AppendLine($" '{LogicalZone}'"); + builder.AppendLine($"'{LogicalZone}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhysicalZone), out propertyOverride); if (Optional.IsDefined(PhysicalZone) || hasPropertyOverride) { - builder.Append(" physicalZone:"); + builder.Append(" physicalZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhysicalZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhysicalZone}'''"); } else { - builder.AppendLine($" '{PhysicalZone}'"); + builder.AppendLine($"'{PhysicalZone}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs index efe855d815643..66be8e09b72bd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs @@ -139,7 +139,7 @@ internal static AzureRoleDefinition DeserializeAzureRoleDefinition(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(Permission.DeserializePermission(item, options)); + array.Add(Permission.DeserializePermission(item)); } permissions = array; continue; @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -225,15 +225,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsServiceRole), out propertyOverride); if (Optional.IsDefined(IsServiceRole) || hasPropertyOverride) { - builder.Append(" isServiceRole:"); + builder.Append(" isServiceRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsServiceRole.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -242,17 +242,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Permissions.Any() || hasPropertyOverride) { - builder.Append(" permissions:"); + builder.Append(" permissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Permissions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " permissions: "); } builder.AppendLine(" ]"); } @@ -264,14 +264,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Scopes.Any() || hasPropertyOverride) { - builder.Append(" scopes:"); + builder.Append(" scopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Scopes) { if (item == null) @@ -298,12 +298,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -324,13 +327,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs index 1e79081889e26..561aee176df09 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -182,14 +182,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedResourceType), out propertyOverride); if (Optional.IsDefined(FullyQualifiedResourceType) || hasPropertyOverride) { - builder.Append(" fullyQualifiedResourceType:"); + builder.Append(" fullyQualifiedResourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FullyQualifiedResourceType.Value.ToString()}'"); + builder.AppendLine($"'{FullyQualifiedResourceType.Value.ToString()}'"); } } @@ -198,14 +198,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DefaultProperties.Any() || hasPropertyOverride) { - builder.Append(" defaultProperties:"); + builder.Append(" defaultProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DefaultProperties) { if (item == null) @@ -231,15 +231,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowCustomProperties), out propertyOverride); if (Optional.IsDefined(AllowCustomProperties) || hasPropertyOverride) { - builder.Append(" allowCustomProperties:"); + builder.Append(" allowCustomProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowCustomProperties.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs index a3827ba512670..40b481a5812f0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -148,14 +148,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetailsSchema), out propertyOverride); if (Optional.IsDefined(DetailsSchema) || hasPropertyOverride) { - builder.Append(" detailsSchema:"); + builder.Append(" detailsSchema: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DetailsSchema.ToString()}'"); + builder.AppendLine($"'{DetailsSchema.ToString()}'"); } } @@ -163,12 +163,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -189,13 +192,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs index ee5c7f9f60026..15495c9749de8 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DataPolicyManifestListResult DeserializeDataPolicyManifestListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DataPolicyManifestData.DeserializeDataPolicyManifestData(item, options)); + array.Add(DataPolicyManifestData.DeserializeDataPolicyManifestData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs index b6d8fb04c7285..8533b8ff4fd47 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs @@ -99,21 +99,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -122,12 +122,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -148,13 +151,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs index 3476feb90dd4a..0a3c6c91fe3ae 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static FeatureOperationsListResult DeserializeFeatureOperationsListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FeatureData.DeserializeFeatureData(item, options)); + array.Add(FeatureData.DeserializeFeatureData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs index 226721feccc77..360cc83665543 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs index 27f96e9649211..24041484b46a2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs @@ -164,7 +164,7 @@ internal static LocationExpanded DeserializeLocationExpanded(JsonElement element { continue; } - metadata = LocationMetadata.DeserializeLocationMetadata(property.Value, options); + metadata = LocationMetadata.DeserializeLocationMetadata(property.Value); continue; } if (property.NameEquals("availabilityZoneMappings"u8)) @@ -176,7 +176,7 @@ internal static LocationExpanded DeserializeLocationExpanded(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(Models.AvailabilityZoneMappings.DeserializeAvailabilityZoneMappings(item, options)); + array.Add(Models.AvailabilityZoneMappings.DeserializeAvailabilityZoneMappings(item)); } availabilityZoneMappings = array; continue; @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -226,21 +226,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -248,21 +248,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) { - builder.Append(" subscriptionId:"); + builder.Append(" subscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubscriptionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubscriptionId}'''"); } else { - builder.AppendLine($" '{SubscriptionId}'"); + builder.AppendLine($"'{SubscriptionId}'"); } } } @@ -270,21 +270,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -292,21 +292,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegionalDisplayName), out propertyOverride); if (Optional.IsDefined(RegionalDisplayName) || hasPropertyOverride) { - builder.Append(" regionalDisplayName:"); + builder.Append(" regionalDisplayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RegionalDisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RegionalDisplayName}'''"); } else { - builder.AppendLine($" '{RegionalDisplayName}'"); + builder.AppendLine($"'{RegionalDisplayName}'"); } } } @@ -314,14 +314,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Metadata, options, 2, false); + AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -330,17 +330,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AvailabilityZoneMappings.Any() || hasPropertyOverride) { - builder.Append(" availabilityZoneMappings:"); + builder.Append(" availabilityZoneMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AvailabilityZoneMappings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " availabilityZoneMappings: "); } builder.AppendLine(" ]"); } @@ -351,12 +351,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -377,13 +380,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs index 45a85050a5a24..c8ad8f2089690 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static LocationListResult DeserializeLocationListResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LocationExpanded.DeserializeLocationExpanded(item, options)); + array.Add(LocationExpanded.DeserializeLocationExpanded(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs index 1871ad852486c..2543956ce3afd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs @@ -182,7 +182,7 @@ internal static LocationMetadata DeserializeLocationMetadata(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PairedRegion.DeserializePairedRegion(item, options)); + array.Add(PairedRegion.DeserializePairedRegion(item)); } pairedRegion = array; continue; @@ -215,49 +215,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegionType), out propertyOverride); if (Optional.IsDefined(RegionType) || hasPropertyOverride) { - builder.Append(" regionType:"); + builder.Append(" regionType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RegionType.Value.ToString()}'"); + builder.AppendLine($"'{RegionType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegionCategory), out propertyOverride); if (Optional.IsDefined(RegionCategory) || hasPropertyOverride) { - builder.Append(" regionCategory:"); + builder.Append(" regionCategory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RegionCategory.Value.ToString()}'"); + builder.AppendLine($"'{RegionCategory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Geography), out propertyOverride); if (Optional.IsDefined(Geography) || hasPropertyOverride) { - builder.Append(" geography:"); + builder.Append(" geography: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Geography.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Geography}'''"); } else { - builder.AppendLine($" '{Geography}'"); + builder.AppendLine($"'{Geography}'"); } } } @@ -265,21 +265,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeographyGroup), out propertyOverride); if (Optional.IsDefined(GeographyGroup) || hasPropertyOverride) { - builder.Append(" geographyGroup:"); + builder.Append(" geographyGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GeographyGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GeographyGroup}'''"); } else { - builder.AppendLine($" '{GeographyGroup}'"); + builder.AppendLine($"'{GeographyGroup}'"); } } } @@ -287,49 +287,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Longitude), out propertyOverride); if (Optional.IsDefined(Longitude) || hasPropertyOverride) { - builder.Append(" longitude:"); + builder.Append(" longitude: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Longitude.Value.ToString()}'"); + builder.AppendLine($"'{Longitude.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Latitude), out propertyOverride); if (Optional.IsDefined(Latitude) || hasPropertyOverride) { - builder.Append(" latitude:"); + builder.Append(" latitude: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Latitude.Value.ToString()}'"); + builder.AppendLine($"'{Latitude.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhysicalLocation), out propertyOverride); if (Optional.IsDefined(PhysicalLocation) || hasPropertyOverride) { - builder.Append(" physicalLocation:"); + builder.Append(" physicalLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhysicalLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhysicalLocation}'''"); } else { - builder.AppendLine($" '{PhysicalLocation}'"); + builder.AppendLine($"'{PhysicalLocation}'"); } } } @@ -339,17 +339,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PairedRegions.Any() || hasPropertyOverride) { - builder.Append(" pairedRegion:"); + builder.Append(" pairedRegion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PairedRegions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " pairedRegion: "); } builder.AppendLine(" ]"); } @@ -359,21 +359,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HomeLocation), out propertyOverride); if (Optional.IsDefined(HomeLocation) || hasPropertyOverride) { - builder.Append(" homeLocation:"); + builder.Append(" homeLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HomeLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HomeLocation}'''"); } else { - builder.AppendLine($" '{HomeLocation}'"); + builder.AppendLine($"'{HomeLocation}'"); } } } @@ -382,12 +382,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -408,13 +411,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs index 3d37fcff91fb5..af726389f3629 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs index 99290a78689b4..8a3ba7b1716d0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagementLockListResult DeserializeManagementLockListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementLockData.DeserializeManagementLockData(item, options)); + array.Add(ManagementLockData.DeserializeManagementLockData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs index 2f651961a7036..74783a6a718e0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationId), out propertyOverride); if (Optional.IsDefined(ApplicationId) || hasPropertyOverride) { - builder.Append(" applicationId:"); + builder.Append(" applicationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApplicationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApplicationId}'''"); } else { - builder.AppendLine($" '{ApplicationId}'"); + builder.AppendLine($"'{ApplicationId}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs index 872814660a1a6..7d07ba53c8fd6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs @@ -112,21 +112,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyDefinitionReferenceId), out propertyOverride); if (Optional.IsDefined(PolicyDefinitionReferenceId) || hasPropertyOverride) { - builder.Append(" policyDefinitionReferenceId:"); + builder.Append(" policyDefinitionReferenceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyDefinitionReferenceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyDefinitionReferenceId}'''"); } else { - builder.AppendLine($" '{PolicyDefinitionReferenceId}'"); + builder.AppendLine($"'{PolicyDefinitionReferenceId}'"); } } } @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs index 2ff77fceff3b8..11d60a4c9d513 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) { - builder.Append(" subscriptionId:"); + builder.Append(" subscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubscriptionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubscriptionId}'''"); } else { - builder.AppendLine($" '{SubscriptionId}'"); + builder.AppendLine($"'{SubscriptionId}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs index d0443d3494640..fe6c4180d6992 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs @@ -135,21 +135,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -157,21 +157,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StrongType), out propertyOverride); if (Optional.IsDefined(StrongType) || hasPropertyOverride) { - builder.Append(" strongType:"); + builder.Append(" strongType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StrongType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StrongType}'''"); } else { - builder.AppendLine($" '{StrongType}'"); + builder.AppendLine($"'{StrongType}'"); } } } @@ -201,15 +201,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AssignPermissions), out propertyOverride); if (Optional.IsDefined(AssignPermissions) || hasPropertyOverride) { - builder.Append(" assignPermissions:"); + builder.Append(" assignPermissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AssignPermissions.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -217,12 +217,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -243,13 +246,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs index 58d645208261e..1db529d14ca42 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs @@ -196,14 +196,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedActions.Any() || hasPropertyOverride) { - builder.Append(" actions:"); + builder.Append(" actions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedActions) { if (item == null) @@ -231,14 +231,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DeniedActions.Any() || hasPropertyOverride) { - builder.Append(" notActions:"); + builder.Append(" notActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DeniedActions) { if (item == null) @@ -266,14 +266,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedDataActions.Any() || hasPropertyOverride) { - builder.Append(" dataActions:"); + builder.Append(" dataActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedDataActions) { if (item == null) @@ -301,14 +301,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DeniedDataActions.Any() || hasPropertyOverride) { - builder.Append(" notDataActions:"); + builder.Append(" notDataActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DeniedDataActions) { if (item == null) @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs index c71ee49b51b47..ff9205f88e324 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static PolicyAssignmentListResult DeserializePolicyAssignmentListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PolicyAssignmentData.DeserializePolicyAssignmentData(item, options)); + array.Add(PolicyAssignmentData.DeserializePolicyAssignmentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs index 7fffbe19e252e..df1f971e42db9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs @@ -142,7 +142,7 @@ internal static PolicyAssignmentPatch DeserializePolicyAssignmentPatch(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ResourceSelector.DeserializeResourceSelector(item, options)); + array.Add(ResourceSelector.DeserializeResourceSelector(item)); } resourceSelectors = array; continue; @@ -156,7 +156,7 @@ internal static PolicyAssignmentPatch DeserializePolicyAssignmentPatch(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PolicyOverride.DeserializePolicyOverride(item, options)); + array.Add(PolicyOverride.DeserializePolicyOverride(item)); } overrides = array; continue; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs index 700997240bfb2..1478c25cc649d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -189,21 +189,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdditionalMetadataId), out propertyOverride); if (Optional.IsDefined(AdditionalMetadataId) || hasPropertyOverride) { - builder.Append(" additionalMetadataId:"); + builder.Append(" additionalMetadataId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AdditionalMetadataId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AdditionalMetadataId}'''"); } else { - builder.AppendLine($" '{AdditionalMetadataId}'"); + builder.AppendLine($"'{AdditionalMetadataId}'"); } } } @@ -256,12 +256,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -282,13 +285,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs index 37960c5aa7fe7..abad833254361 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static PolicyDefinitionListResult DeserializePolicyDefinitionListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PolicyDefinitionData.DeserializePolicyDefinitionData(item, options)); + array.Add(PolicyDefinitionData.DeserializePolicyDefinitionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs index 2e68a226bd8ee..fa31691c32d3e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs @@ -117,7 +117,7 @@ internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(J Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(property0.Name, ArmPolicyParameterValue.DeserializeArmPolicyParameterValue(property0.Value, options)); + dictionary.Add(property0.Name, ArmPolicyParameterValue.DeserializeArmPolicyParameterValue(property0.Value)); } parameters = dictionary; continue; @@ -164,21 +164,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyDefinitionId), out propertyOverride); if (Optional.IsDefined(PolicyDefinitionId) || hasPropertyOverride) { - builder.Append(" policyDefinitionId:"); + builder.Append(" policyDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyDefinitionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyDefinitionId}'''"); } else { - builder.AppendLine($" '{PolicyDefinitionId}'"); + builder.AppendLine($"'{PolicyDefinitionId}'"); } } } @@ -188,18 +188,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Parameters.Any() || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Parameters) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " parameters: "); } builder.AppendLine(" }"); } @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyDefinitionReferenceId), out propertyOverride); if (Optional.IsDefined(PolicyDefinitionReferenceId) || hasPropertyOverride) { - builder.Append(" policyDefinitionReferenceId:"); + builder.Append(" policyDefinitionReferenceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyDefinitionReferenceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyDefinitionReferenceId}'''"); } else { - builder.AppendLine($" '{PolicyDefinitionReferenceId}'"); + builder.AppendLine($"'{PolicyDefinitionReferenceId}'"); } } } @@ -233,14 +233,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GroupNames.Any() || hasPropertyOverride) { - builder.Append(" groupNames:"); + builder.Append(" groupNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GroupNames) { if (item == null) @@ -267,12 +267,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -293,13 +296,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs index 0ea189858c5c4..97d2c3f577645 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs @@ -117,7 +117,7 @@ internal static PolicyOverride DeserializePolicyOverride(JsonElement element, Mo List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceSelectorExpression.DeserializeResourceSelectorExpression(item, options)); + array.Add(ResourceSelectorExpression.DeserializeResourceSelectorExpression(item)); } selectors = array; continue; @@ -145,35 +145,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.Value.ToString()}'"); + builder.AppendLine($"'{Kind.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -183,17 +183,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Selectors.Any() || hasPropertyOverride) { - builder.Append(" selectors:"); + builder.Append(" selectors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Selectors) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " selectors: "); } builder.AppendLine(" ]"); } @@ -204,12 +204,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -230,13 +233,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs index cae73593b2e4c..8bfced5ccb422 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static PolicySetDefinitionListResult DeserializePolicySetDefinitionList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PolicySetDefinitionData.DeserializePolicySetDefinitionData(item, options)); + array.Add(PolicySetDefinitionData.DeserializePolicySetDefinitionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs index 796c146ec2d23..bbcec9a97ff05 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs @@ -116,7 +116,7 @@ internal static PredefinedTag DeserializePredefinedTag(JsonElement element, Mode { continue; } - count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value, options); + count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value); continue; } if (property.NameEquals("values"u8)) @@ -128,7 +128,7 @@ internal static PredefinedTag DeserializePredefinedTag(JsonElement element, Mode List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PredefinedTagValue.DeserializePredefinedTagValue(item, options)); + array.Add(PredefinedTagValue.DeserializePredefinedTagValue(item)); } values = array; continue; @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TagName), out propertyOverride); if (Optional.IsDefined(TagName) || hasPropertyOverride) { - builder.Append(" tagName:"); + builder.Append(" tagName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TagName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TagName}'''"); } else { - builder.AppendLine($" '{TagName}'"); + builder.AppendLine($"'{TagName}'"); } } } @@ -200,14 +200,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Count, options, 2, false); + AppendChildObject(builder, Count, options, 2, false, " count: "); } } @@ -216,17 +216,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Values.Any() || hasPropertyOverride) { - builder.Append(" values:"); + builder.Append(" values: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Values) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " values: "); } builder.AppendLine(" ]"); } @@ -237,12 +237,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -263,13 +266,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs index 5a5a847f14ceb..03759ae3c8169 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs @@ -119,14 +119,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Value.Value}"); + builder.AppendLine($"{Value.Value}"); } } @@ -134,12 +134,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -160,13 +163,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs index ee15628cbd5ca..3ecb81c2b0723 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs @@ -104,7 +104,7 @@ internal static PredefinedTagValue DeserializePredefinedTagValue(JsonElement ele { continue; } - count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value, options); + count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value); continue; } if (options.Format != "W") @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TagValue), out propertyOverride); if (Optional.IsDefined(TagValue) || hasPropertyOverride) { - builder.Append(" tagValue:"); + builder.Append(" tagValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TagValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TagValue}'''"); } else { - builder.AppendLine($" '{TagValue}'"); + builder.AppendLine($"'{TagValue}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Count, options, 2, false); + AppendChildObject(builder, Count, options, 2, false, " count: "); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs index a2db499ba7316..dccca37c419ab 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static PredefinedTagsListResult DeserializePredefinedTagsListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(PredefinedTag.DeserializePredefinedTag(item, options)); + array.Add(PredefinedTag.DeserializePredefinedTag(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs index 38fd2d124544d..be05676aa4d81 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs @@ -145,14 +145,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -161,14 +161,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExtendedLocations.Any() || hasPropertyOverride) { - builder.Append(" extendedLocations:"); + builder.Append(" extendedLocations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExtendedLocations) { if (item == null) @@ -195,12 +195,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -221,13 +224,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs index 279e180b41cf4..a128a5b42d0d2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs @@ -105,7 +105,7 @@ internal static ProviderPermission DeserializeProviderPermission(JsonElement ele { continue; } - roleDefinition = AzureRoleDefinition.DeserializeAzureRoleDefinition(property.Value, options); + roleDefinition = AzureRoleDefinition.DeserializeAzureRoleDefinition(property.Value); continue; } if (property.NameEquals("managedByRoleDefinition"u8)) @@ -114,7 +114,7 @@ internal static ProviderPermission DeserializeProviderPermission(JsonElement ele { continue; } - managedByRoleDefinition = AzureRoleDefinition.DeserializeAzureRoleDefinition(property.Value, options); + managedByRoleDefinition = AzureRoleDefinition.DeserializeAzureRoleDefinition(property.Value); continue; } if (property.NameEquals("providerAuthorizationConsentState"u8)) @@ -149,21 +149,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationId), out propertyOverride); if (Optional.IsDefined(ApplicationId) || hasPropertyOverride) { - builder.Append(" applicationId:"); + builder.Append(" applicationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApplicationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApplicationId}'''"); } else { - builder.AppendLine($" '{ApplicationId}'"); + builder.AppendLine($"'{ApplicationId}'"); } } } @@ -171,42 +171,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoleDefinition), out propertyOverride); if (Optional.IsDefined(RoleDefinition) || hasPropertyOverride) { - builder.Append(" roleDefinition:"); + builder.Append(" roleDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RoleDefinition, options, 2, false); + AppendChildObject(builder, RoleDefinition, options, 2, false, " roleDefinition: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedByRoleDefinition), out propertyOverride); if (Optional.IsDefined(ManagedByRoleDefinition) || hasPropertyOverride) { - builder.Append(" managedByRoleDefinition:"); + builder.Append(" managedByRoleDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ManagedByRoleDefinition, options, 2, false); + AppendChildObject(builder, ManagedByRoleDefinition, options, 2, false, " managedByRoleDefinition: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderAuthorizationConsentState), out propertyOverride); if (Optional.IsDefined(ProviderAuthorizationConsentState) || hasPropertyOverride) { - builder.Append(" providerAuthorizationConsentState:"); + builder.Append(" providerAuthorizationConsentState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProviderAuthorizationConsentState.Value.ToString()}'"); + builder.AppendLine($"'{ProviderAuthorizationConsentState.Value.ToString()}'"); } } @@ -214,12 +214,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -240,13 +243,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs index 1f2b6c791aa69..92f7ac6c135bd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ProviderPermissionListResult DeserializeProviderPermissionListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ProviderPermission.DeserializeProviderPermission(item, options)); + array.Add(ProviderPermission.DeserializeProviderPermission(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs index 1d276547bd810..52c26f0f03b71 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs @@ -80,7 +80,7 @@ internal static ProviderRegistrationContent DeserializeProviderRegistrationConte { continue; } - thirdPartyProviderConsent = ProviderConsentDefinition.DeserializeProviderConsentDefinition(property.Value, options); + thirdPartyProviderConsent = ProviderConsentDefinition.DeserializeProviderConsentDefinition(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs index b77ea7b6f92b9..cf6520667921e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs @@ -195,7 +195,7 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ProviderExtendedLocation.DeserializeProviderExtendedLocation(item, options)); + array.Add(ProviderExtendedLocation.DeserializeProviderExtendedLocation(item)); } locationMappings = array; continue; @@ -209,7 +209,7 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceTypeAlias.DeserializeResourceTypeAlias(item, options)); + array.Add(ResourceTypeAlias.DeserializeResourceTypeAlias(item)); } aliases = array; continue; @@ -242,7 +242,7 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ZoneMapping.DeserializeZoneMapping(item, options)); + array.Add(ZoneMapping.DeserializeZoneMapping(item)); } zoneMappings = array; continue; @@ -256,7 +256,7 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ApiProfile.DeserializeApiProfile(item, options)); + array.Add(ApiProfile.DeserializeApiProfile(item)); } apiProfiles = array; continue; @@ -303,21 +303,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceType}'''"); } else { - builder.AppendLine($" '{ResourceType}'"); + builder.AppendLine($"'{ResourceType}'"); } } } @@ -327,14 +327,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Locations.Any() || hasPropertyOverride) { - builder.Append(" locations:"); + builder.Append(" locations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Locations) { if (item == null) @@ -362,17 +362,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LocationMappings.Any() || hasPropertyOverride) { - builder.Append(" locationMappings:"); + builder.Append(" locationMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LocationMappings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " locationMappings: "); } builder.AppendLine(" ]"); } @@ -384,17 +384,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Aliases.Any() || hasPropertyOverride) { - builder.Append(" aliases:"); + builder.Append(" aliases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Aliases) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " aliases: "); } builder.AppendLine(" ]"); } @@ -406,14 +406,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ApiVersions.Any() || hasPropertyOverride) { - builder.Append(" apiVersions:"); + builder.Append(" apiVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ApiVersions) { if (item == null) @@ -439,21 +439,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultApiVersion), out propertyOverride); if (Optional.IsDefined(DefaultApiVersion) || hasPropertyOverride) { - builder.Append(" defaultApiVersion:"); + builder.Append(" defaultApiVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultApiVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultApiVersion}'''"); } else { - builder.AppendLine($" '{DefaultApiVersion}'"); + builder.AppendLine($"'{DefaultApiVersion}'"); } } } @@ -463,17 +463,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ZoneMappings.Any() || hasPropertyOverride) { - builder.Append(" zoneMappings:"); + builder.Append(" zoneMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ZoneMappings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " zoneMappings: "); } builder.AppendLine(" ]"); } @@ -485,17 +485,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ApiProfiles.Any() || hasPropertyOverride) { - builder.Append(" apiProfiles:"); + builder.Append(" apiProfiles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ApiProfiles) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " apiProfiles: "); } builder.AppendLine(" ]"); } @@ -505,21 +505,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capabilities), out propertyOverride); if (Optional.IsDefined(Capabilities) || hasPropertyOverride) { - builder.Append(" capabilities:"); + builder.Append(" capabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Capabilities.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Capabilities}'''"); } else { - builder.AppendLine($" '{Capabilities}'"); + builder.AppendLine($"'{Capabilities}'"); } } } @@ -529,17 +529,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Properties) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -547,12 +547,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -564,12 +564,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -590,13 +593,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs index f68bf29ad33ab..013c396b78983 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ProviderResourceTypeListResult DeserializeProviderResourceTypeLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ProviderResourceType.DeserializeProviderResourceType(item, options)); + array.Add(ProviderResourceType.DeserializeProviderResourceType(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs index 4fac220c7237b..f1f544732a000 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs @@ -131,28 +131,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); if (Optional.IsDefined(Template) || hasPropertyOverride) { - builder.Append(" template:"); + builder.Append(" template: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Template.ToString()}'"); + builder.AppendLine($"'{Template.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs index f99c2c00552f9..de9dc3627a46a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ResourceGroupListResult DeserializeResourceGroupListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceGroupData.DeserializeResourceGroupData(item, options)); + array.Add(ResourceGroupData.DeserializeResourceGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs index c0c39ac2e8665..66c23365d7c76 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs @@ -109,7 +109,7 @@ internal static ResourceGroupPatch DeserializeResourceGroupPatch(JsonElement ele { continue; } - properties = ResourceGroupProperties.DeserializeResourceGroupProperties(property.Value, options); + properties = ResourceGroupProperties.DeserializeResourceGroupProperties(property.Value); continue; } if (property.NameEquals("managedBy"u8)) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs index d7d4515b02b7e..a08d2406de8cf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs index ca329a61c3017..6b6d05c96b7a0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ResourceListResult DeserializeResourceListResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(GenericResourceData.DeserializeGenericResourceData(item, options)); + array.Add(GenericResourceData.DeserializeGenericResourceData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs index 055be4c32c99f..f8c7110ae5380 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,14 +156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs index fd518442505a8..eb5887a9e8ca7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ResourceProviderListResult DeserializeResourceProviderListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceProviderData.DeserializeResourceProviderData(item, options)); + array.Add(ResourceProviderData.DeserializeResourceProviderData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs index 9b2aa86113943..9d94d7e5097ae 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs @@ -102,7 +102,7 @@ internal static ResourceSelector DeserializeResourceSelector(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceSelectorExpression.DeserializeResourceSelectorExpression(item, options)); + array.Add(ResourceSelectorExpression.DeserializeResourceSelectorExpression(item)); } selectors = array; continue; @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Selectors.Any() || hasPropertyOverride) { - builder.Append(" selectors:"); + builder.Append(" selectors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Selectors) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " selectors: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs index f486fd86f85db..0ae948e1bca54 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs @@ -159,14 +159,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.Value.ToString()}'"); + builder.AppendLine($"'{Kind.Value.ToString()}'"); } } @@ -175,14 +175,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (In.Any() || hasPropertyOverride) { - builder.Append(" in:"); + builder.Append(" in: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in In) { if (item == null) @@ -210,14 +210,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NotIn.Any() || hasPropertyOverride) { - builder.Append(" notIn:"); + builder.Append(" notIn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NotIn) { if (item == null) @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs index fce27d818c456..6675e0a287147 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs @@ -126,7 +126,7 @@ internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceTypeAliasPath.DeserializeResourceTypeAliasPath(item, options)); + array.Add(ResourceTypeAliasPath.DeserializeResourceTypeAliasPath(item)); } paths = array; continue; @@ -151,7 +151,7 @@ internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement eleme { continue; } - defaultPattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value, options); + defaultPattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value); continue; } if (property.NameEquals("defaultMetadata"u8)) @@ -160,7 +160,7 @@ internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement eleme { continue; } - defaultMetadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value, options); + defaultMetadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value); continue; } if (options.Format != "W") @@ -186,21 +186,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,17 +210,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Paths.Any() || hasPropertyOverride) { - builder.Append(" paths:"); + builder.Append(" paths: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Paths) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " paths: "); } builder.AppendLine(" ]"); } @@ -230,21 +230,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultPath), out propertyOverride); if (Optional.IsDefined(DefaultPath) || hasPropertyOverride) { - builder.Append(" defaultPath:"); + builder.Append(" defaultPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultPath}'''"); } else { - builder.AppendLine($" '{DefaultPath}'"); + builder.AppendLine($"'{DefaultPath}'"); } } } @@ -252,28 +252,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultPattern), out propertyOverride); if (Optional.IsDefined(DefaultPattern) || hasPropertyOverride) { - builder.Append(" defaultPattern:"); + builder.Append(" defaultPattern: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DefaultPattern, options, 2, false); + AppendChildObject(builder, DefaultPattern, options, 2, false, " defaultPattern: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultMetadata), out propertyOverride); if (Optional.IsDefined(DefaultMetadata) || hasPropertyOverride) { - builder.Append(" defaultMetadata:"); + builder.Append(" defaultMetadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DefaultMetadata, options, 2, false); + AppendChildObject(builder, DefaultMetadata, options, 2, false, " defaultMetadata: "); } } @@ -281,12 +281,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -307,13 +310,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs index 9d78ef1ba0620..f1f7ca0c939d6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs @@ -125,7 +125,7 @@ internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonEleme { continue; } - pattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value, options); + pattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value); continue; } if (property.NameEquals("metadata"u8)) @@ -134,7 +134,7 @@ internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonEleme { continue; } - metadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value, options); + metadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value); continue; } if (options.Format != "W") @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -184,14 +184,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ApiVersions.Any() || hasPropertyOverride) { - builder.Append(" apiVersions:"); + builder.Append(" apiVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ApiVersions) { if (item == null) @@ -217,28 +217,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Pattern), out propertyOverride); if (Optional.IsDefined(Pattern) || hasPropertyOverride) { - builder.Append(" pattern:"); + builder.Append(" pattern: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Pattern, options, 2, false); + AppendChildObject(builder, Pattern, options, 2, false, " pattern: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Metadata, options, 2, false); + AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -246,12 +246,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -272,13 +275,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs index 27b392046b853..76c7078b3a8ce 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs @@ -123,14 +123,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); if (Optional.IsDefined(Attributes) || hasPropertyOverride) { - builder.Append(" attributes:"); + builder.Append(" attributes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Attributes.Value.ToString()}'"); + builder.AppendLine($"'{Attributes.Value.ToString()}'"); } } @@ -138,12 +138,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -164,13 +167,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs index 5a40fa0ae026d..3c65833d9a84b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Phrase), out propertyOverride); if (Optional.IsDefined(Phrase) || hasPropertyOverride) { - builder.Append(" phrase:"); + builder.Append(" phrase: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Phrase.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Phrase}'''"); } else { - builder.AppendLine($" '{Phrase}'"); + builder.AppendLine($"'{Phrase}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Variable), out propertyOverride); if (Optional.IsDefined(Variable) || hasPropertyOverride) { - builder.Append(" variable:"); + builder.Append(" variable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Variable.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Variable}'''"); } else { - builder.AppendLine($" '{Variable}'"); + builder.AppendLine($"'{Variable}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs index 283deca4e961e..4d51413878ee2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs @@ -102,7 +102,7 @@ internal static ResourceTypeAliases DeserializeResourceTypeAliases(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ResourceTypeAlias.DeserializeResourceTypeAlias(item, options)); + array.Add(ResourceTypeAlias.DeserializeResourceTypeAlias(item)); } aliases = array; continue; @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceType}'''"); } else { - builder.AppendLine($" '{ResourceType}'"); + builder.AppendLine($"'{ResourceType}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Aliases.Any() || hasPropertyOverride) { - builder.Append(" aliases:"); + builder.Append(" aliases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Aliases) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " aliases: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs index c3511a8e0b3ed..bf73b8abbfa75 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -185,21 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Model), out propertyOverride); if (Optional.IsDefined(Model) || hasPropertyOverride) { - builder.Append(" model:"); + builder.Append(" model: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Model.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Model}'''"); } else { - builder.AppendLine($" '{Model}'"); + builder.AppendLine($"'{Model}'"); } } } @@ -273,14 +273,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Capacity.Value}"); + builder.AppendLine($"{Capacity.Value}"); } } @@ -288,12 +288,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -314,13 +317,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs index a0f20bd8f8f32..b0c4f8797c212 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs @@ -95,7 +95,7 @@ internal static SubscriptionListResult DeserializeSubscriptionListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SubscriptionData.DeserializeSubscriptionData(item, options)); + array.Add(SubscriptionData.DeserializeSubscriptionData(item)); } value = array; continue; @@ -130,17 +130,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -150,21 +150,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -173,12 +173,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -199,13 +202,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs index 4e9bf0e419eab..9e67a936f2d68 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocationPlacementId), out propertyOverride); if (Optional.IsDefined(LocationPlacementId) || hasPropertyOverride) { - builder.Append(" locationPlacementId:"); + builder.Append(" locationPlacementId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocationPlacementId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocationPlacementId}'''"); } else { - builder.AppendLine($" '{LocationPlacementId}'"); + builder.AppendLine($"'{LocationPlacementId}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotaId), out propertyOverride); if (Optional.IsDefined(QuotaId) || hasPropertyOverride) { - builder.Append(" quotaId:"); + builder.Append(" quotaId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QuotaId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QuotaId}'''"); } else { - builder.AppendLine($" '{QuotaId}'"); + builder.AppendLine($"'{QuotaId}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SpendingLimit), out propertyOverride); if (Optional.IsDefined(SpendingLimit) || hasPropertyOverride) { - builder.Append(" spendingLimit:"); + builder.Append(" spendingLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SpendingLimit.Value.ToSerialString()}'"); + builder.AppendLine($"'{SpendingLimit.Value.ToSerialString()}'"); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs index 1fe25936451d3..e336465571ed0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TagValues.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in TagValues) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -140,12 +140,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs index f6008739b0a58..4a437d5fb7f08 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs @@ -95,7 +95,7 @@ internal static TagResourcePatch DeserializeTagResourcePatch(JsonElement element { continue; } - properties = Tag.DeserializeTag(property.Value, options); + properties = Tag.DeserializeTag(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs index c11b5aee1d6e4..730d85d911988 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs @@ -95,7 +95,7 @@ internal static TenantListResult DeserializeTenantListResult(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TenantData.DeserializeTenantData(item, options)); + array.Add(TenantData.DeserializeTenantData(item)); } value = array; continue; @@ -130,17 +130,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -150,21 +150,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -173,12 +173,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -199,13 +202,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs index 036339586dc73..738631fb9feac 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs @@ -102,7 +102,7 @@ internal static TenantResourceProvider DeserializeTenantResourceProvider(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ProviderResourceType.DeserializeProviderResourceType(item, options)); + array.Add(ProviderResourceType.DeserializeProviderResourceType(item)); } resourceTypes = array; continue; @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Namespace), out propertyOverride); if (Optional.IsDefined(Namespace) || hasPropertyOverride) { - builder.Append(" namespace:"); + builder.Append(" namespace: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Namespace.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Namespace}'''"); } else { - builder.AppendLine($" '{Namespace}'"); + builder.AppendLine($"'{Namespace}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResourceTypes.Any() || hasPropertyOverride) { - builder.Append(" resourceTypes:"); + builder.Append(" resourceTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResourceTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs index 2a1dba633b6d0..2f84507ce243c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static TenantResourceProviderListResult DeserializeTenantResourceProvid List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TenantResourceProvider.DeserializeTenantResourceProvider(item, options)); + array.Add(TenantResourceProvider.DeserializeTenantResourceProvider(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs index 61227327e499c..4e8f6678f726a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs @@ -192,21 +192,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -214,14 +214,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -230,17 +230,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -248,12 +248,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -264,42 +264,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -307,12 +307,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -333,13 +336,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs index 4919fb97b4c31..8f5e9f854e32b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs @@ -134,14 +134,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -150,14 +150,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Zones.Any() || hasPropertyOverride) { - builder.Append(" zones:"); + builder.Append(" zones: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Zones) { if (item == null) @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs index 35e619bc76211..377013a09112b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs @@ -300,7 +300,7 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, ArmPolicyParameterValue.DeserializeArmPolicyParameterValue(property1.Value, options)); + dictionary.Add(property1.Name, ArmPolicyParameterValue.DeserializeArmPolicyParameterValue(property1.Value)); } parameters = dictionary; continue; @@ -337,7 +337,7 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(NonComplianceMessage.DeserializeNonComplianceMessage(item, options)); + array.Add(NonComplianceMessage.DeserializeNonComplianceMessage(item)); } nonComplianceMessages = array; continue; @@ -351,7 +351,7 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ResourceSelector.DeserializeResourceSelector(item, options)); + array.Add(ResourceSelector.DeserializeResourceSelector(item)); } resourceSelectors = array; continue; @@ -365,7 +365,7 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PolicyOverride.DeserializePolicyOverride(item, options)); + array.Add(PolicyOverride.DeserializePolicyOverride(item)); } overrides = array; continue; @@ -396,21 +396,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -418,56 +418,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedIdentity), out propertyOverride); if (Optional.IsDefined(ManagedIdentity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ManagedIdentity, options, 2, false); + AppendChildObject(builder, ManagedIdentity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -476,21 +476,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -498,21 +498,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyDefinitionId), out propertyOverride); if (Optional.IsDefined(PolicyDefinitionId) || hasPropertyOverride) { - builder.Append(" policyDefinitionId:"); + builder.Append(" policyDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyDefinitionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyDefinitionId}'''"); } else { - builder.AppendLine($" '{PolicyDefinitionId}'"); + builder.AppendLine($"'{PolicyDefinitionId}'"); } } } @@ -520,21 +520,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scope), out propertyOverride); if (Optional.IsDefined(Scope) || hasPropertyOverride) { - builder.Append(" scope:"); + builder.Append(" scope: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Scope.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Scope}'''"); } else { - builder.AppendLine($" '{Scope}'"); + builder.AppendLine($"'{Scope}'"); } } } @@ -544,14 +544,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExcludedScopes.Any() || hasPropertyOverride) { - builder.Append(" notScopes:"); + builder.Append(" notScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExcludedScopes) { if (item == null) @@ -579,18 +579,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Parameters.Any() || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Parameters) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -600,21 +600,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -622,28 +622,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Metadata.ToString()}'"); + builder.AppendLine($"'{Metadata.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnforcementMode), out propertyOverride); if (Optional.IsDefined(EnforcementMode) || hasPropertyOverride) { - builder.Append(" enforcementMode:"); + builder.Append(" enforcementMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{EnforcementMode.Value.ToString()}'"); + builder.AppendLine($"'{EnforcementMode.Value.ToString()}'"); } } @@ -652,17 +652,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NonComplianceMessages.Any() || hasPropertyOverride) { - builder.Append(" nonComplianceMessages:"); + builder.Append(" nonComplianceMessages: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NonComplianceMessages) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " nonComplianceMessages: "); } builder.AppendLine(" ]"); } @@ -674,17 +674,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResourceSelectors.Any() || hasPropertyOverride) { - builder.Append(" resourceSelectors:"); + builder.Append(" resourceSelectors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResourceSelectors) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " resourceSelectors: "); } builder.AppendLine(" ]"); } @@ -696,17 +696,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Overrides.Any() || hasPropertyOverride) { - builder.Append(" overrides:"); + builder.Append(" overrides: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Overrides) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " overrides: "); } builder.AppendLine(" ]"); } @@ -718,12 +718,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -744,13 +747,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs index e80a244b11335..009ac0410a24f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs @@ -246,7 +246,7 @@ internal static PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, ArmPolicyParameter.DeserializeArmPolicyParameter(property1.Value, options)); + dictionary.Add(property1.Name, ArmPolicyParameter.DeserializeArmPolicyParameter(property1.Value)); } parameters = dictionary; continue; @@ -277,21 +277,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -299,28 +299,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -329,35 +329,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyType), out propertyOverride); if (Optional.IsDefined(PolicyType) || hasPropertyOverride) { - builder.Append(" policyType:"); + builder.Append(" policyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PolicyType.Value.ToString()}'"); + builder.AppendLine($"'{PolicyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mode), out propertyOverride); if (Optional.IsDefined(Mode) || hasPropertyOverride) { - builder.Append(" mode:"); + builder.Append(" mode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Mode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Mode}'''"); } else { - builder.AppendLine($" '{Mode}'"); + builder.AppendLine($"'{Mode}'"); } } } @@ -365,21 +365,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -387,21 +387,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -409,28 +409,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyRule), out propertyOverride); if (Optional.IsDefined(PolicyRule) || hasPropertyOverride) { - builder.Append(" policyRule:"); + builder.Append(" policyRule: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PolicyRule.ToString()}'"); + builder.AppendLine($"'{PolicyRule.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Metadata.ToString()}'"); + builder.AppendLine($"'{Metadata.ToString()}'"); } } @@ -439,18 +439,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Parameters.Any() || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Parameters) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -462,12 +462,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -488,13 +491,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs index 7eabf0ab5bf7c..c989a9c1179a4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs @@ -235,7 +235,7 @@ internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonE Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, ArmPolicyParameter.DeserializeArmPolicyParameter(property1.Value, options)); + dictionary.Add(property1.Name, ArmPolicyParameter.DeserializeArmPolicyParameter(property1.Value)); } parameters = dictionary; continue; @@ -249,7 +249,7 @@ internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PolicyDefinitionReference.DeserializePolicyDefinitionReference(item, options)); + array.Add(PolicyDefinitionReference.DeserializePolicyDefinitionReference(item)); } policyDefinitions = array; continue; @@ -263,7 +263,7 @@ internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PolicyDefinitionGroup.DeserializePolicyDefinitionGroup(item, options)); + array.Add(PolicyDefinitionGroup.DeserializePolicyDefinitionGroup(item)); } policyDefinitionGroups = array; continue; @@ -294,21 +294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -316,28 +316,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -346,35 +346,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyType), out propertyOverride); if (Optional.IsDefined(PolicyType) || hasPropertyOverride) { - builder.Append(" policyType:"); + builder.Append(" policyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PolicyType.Value.ToString()}'"); + builder.AppendLine($"'{PolicyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -382,21 +382,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -404,14 +404,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Metadata.ToString()}'"); + builder.AppendLine($"'{Metadata.ToString()}'"); } } @@ -420,18 +420,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Parameters.Any() || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Parameters) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -443,17 +443,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PolicyDefinitions.Any() || hasPropertyOverride) { - builder.Append(" policyDefinitions:"); + builder.Append(" policyDefinitions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PolicyDefinitions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " policyDefinitions: "); } builder.AppendLine(" ]"); } @@ -465,17 +465,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PolicyDefinitionGroups.Any() || hasPropertyOverride) { - builder.Append(" policyDefinitionGroups:"); + builder.Append(" policyDefinitionGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PolicyDefinitionGroups) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " policyDefinitionGroups: "); } builder.AppendLine(" ]"); } @@ -487,12 +487,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -513,13 +516,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs index 84e15c9d3a73f..6f26938c31b8d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs @@ -130,7 +130,7 @@ internal static ResourceGroupData DeserializeResourceGroupData(JsonElement eleme { continue; } - properties = ResourceGroupProperties.DeserializeResourceGroupProperties(property.Value, options); + properties = ResourceGroupProperties.DeserializeResourceGroupProperties(property.Value); continue; } if (property.NameEquals("managedBy"u8)) @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -226,14 +226,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -242,17 +242,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -260,12 +260,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -276,35 +276,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -312,28 +312,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -341,12 +341,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -367,13 +370,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs index 39725cee6e269..3fe1a76583bbb 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs @@ -146,7 +146,7 @@ internal static ResourceProviderData DeserializeResourceProviderData(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ProviderResourceType.DeserializeProviderResourceType(item, options)); + array.Add(ProviderResourceType.DeserializeProviderResourceType(item)); } resourceTypes = array; continue; @@ -183,35 +183,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Namespace), out propertyOverride); if (Optional.IsDefined(Namespace) || hasPropertyOverride) { - builder.Append(" namespace:"); + builder.Append(" namespace: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Namespace.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Namespace}'''"); } else { - builder.AppendLine($" '{Namespace}'"); + builder.AppendLine($"'{Namespace}'"); } } } @@ -219,21 +219,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistrationState), out propertyOverride); if (Optional.IsDefined(RegistrationState) || hasPropertyOverride) { - builder.Append(" registrationState:"); + builder.Append(" registrationState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RegistrationState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RegistrationState}'''"); } else { - builder.AppendLine($" '{RegistrationState}'"); + builder.AppendLine($"'{RegistrationState}'"); } } } @@ -241,21 +241,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistrationPolicy), out propertyOverride); if (Optional.IsDefined(RegistrationPolicy) || hasPropertyOverride) { - builder.Append(" registrationPolicy:"); + builder.Append(" registrationPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RegistrationPolicy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RegistrationPolicy}'''"); } else { - builder.AppendLine($" '{RegistrationPolicy}'"); + builder.AppendLine($"'{RegistrationPolicy}'"); } } } @@ -265,17 +265,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResourceTypes.Any() || hasPropertyOverride) { - builder.Append(" resourceTypes:"); + builder.Append(" resourceTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResourceTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); } builder.AppendLine(" ]"); } @@ -285,14 +285,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderAuthorizationConsentState), out propertyOverride); if (Optional.IsDefined(ProviderAuthorizationConsentState) || hasPropertyOverride) { - builder.Append(" providerAuthorizationConsentState:"); + builder.Append(" providerAuthorizationConsentState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProviderAuthorizationConsentState.Value.ToString()}'"); + builder.AppendLine($"'{ProviderAuthorizationConsentState.Value.ToString()}'"); } } @@ -300,12 +300,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -326,13 +329,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs index 683315eb9deb5..7c3f5156d6d97 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs @@ -180,7 +180,7 @@ internal static SubscriptionData DeserializeSubscriptionData(JsonElement element { continue; } - subscriptionPolicies = SubscriptionPolicies.DeserializeSubscriptionPolicies(property.Value, options); + subscriptionPolicies = SubscriptionPolicies.DeserializeSubscriptionPolicies(property.Value); continue; } if (property.NameEquals("authorizationSource"u8)) @@ -197,7 +197,7 @@ internal static SubscriptionData DeserializeSubscriptionData(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedByTenant.DeserializeManagedByTenant(item, options)); + array.Add(ManagedByTenant.DeserializeManagedByTenant(item)); } managedByTenants = array; continue; @@ -241,17 +241,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -259,12 +259,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -275,35 +275,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) { - builder.Append(" subscriptionId:"); + builder.Append(" subscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubscriptionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubscriptionId}'''"); } else { - builder.AppendLine($" '{SubscriptionId}'"); + builder.AppendLine($"'{SubscriptionId}'"); } } } @@ -311,21 +311,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -333,63 +333,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionPolicies), out propertyOverride); if (Optional.IsDefined(SubscriptionPolicies) || hasPropertyOverride) { - builder.Append(" subscriptionPolicies:"); + builder.Append(" subscriptionPolicies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SubscriptionPolicies, options, 2, false); + AppendChildObject(builder, SubscriptionPolicies, options, 2, false, " subscriptionPolicies: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthorizationSource), out propertyOverride); if (Optional.IsDefined(AuthorizationSource) || hasPropertyOverride) { - builder.Append(" authorizationSource:"); + builder.Append(" authorizationSource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthorizationSource.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthorizationSource}'''"); } else { - builder.AppendLine($" '{AuthorizationSource}'"); + builder.AppendLine($"'{AuthorizationSource}'"); } } } @@ -399,17 +399,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagedByTenants.Any() || hasPropertyOverride) { - builder.Append(" managedByTenants:"); + builder.Append(" managedByTenants: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagedByTenants) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " managedByTenants: "); } builder.AppendLine(" ]"); } @@ -420,12 +420,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -446,13 +449,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs index 423d6faa6e121..08f0c52bf69c9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs @@ -101,7 +101,7 @@ internal static TagResourceData DeserializeTagResourceData(JsonElement element, { if (property.NameEquals("properties"u8)) { - properties = Tag.DeserializeTag(property.Value, options); + properties = Tag.DeserializeTag(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -151,21 +151,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -173,42 +173,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -216,12 +216,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -242,13 +245,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs index e31e39dc44538..13bc54281c7d1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -253,49 +253,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantCategory), out propertyOverride); if (Optional.IsDefined(TenantCategory) || hasPropertyOverride) { - builder.Append(" tenantCategory:"); + builder.Append(" tenantCategory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantCategory.Value.ToSerialString()}'"); + builder.AppendLine($"'{TenantCategory.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Country), out propertyOverride); if (Optional.IsDefined(Country) || hasPropertyOverride) { - builder.Append(" country:"); + builder.Append(" country: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Country.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Country}'''"); } else { - builder.AppendLine($" '{Country}'"); + builder.AppendLine($"'{Country}'"); } } } @@ -303,21 +303,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CountryCode), out propertyOverride); if (Optional.IsDefined(CountryCode) || hasPropertyOverride) { - builder.Append(" countryCode:"); + builder.Append(" countryCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CountryCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CountryCode}'''"); } else { - builder.AppendLine($" '{CountryCode}'"); + builder.AppendLine($"'{CountryCode}'"); } } } @@ -325,21 +325,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -349,14 +349,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Domains.Any() || hasPropertyOverride) { - builder.Append(" domains:"); + builder.Append(" domains: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Domains) { if (item == null) @@ -382,21 +382,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDomain), out propertyOverride); if (Optional.IsDefined(DefaultDomain) || hasPropertyOverride) { - builder.Append(" defaultDomain:"); + builder.Append(" defaultDomain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultDomain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultDomain}'''"); } else { - builder.AppendLine($" '{DefaultDomain}'"); + builder.AppendLine($"'{DefaultDomain}'"); } } } @@ -404,21 +404,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantType), out propertyOverride); if (Optional.IsDefined(TenantType) || hasPropertyOverride) { - builder.Append(" tenantType:"); + builder.Append(" tenantType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TenantType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TenantType}'''"); } else { - builder.AppendLine($" '{TenantType}'"); + builder.AppendLine($"'{TenantType}'"); } } } @@ -426,14 +426,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantBrandingLogoUri), out propertyOverride); if (Optional.IsDefined(TenantBrandingLogoUri) || hasPropertyOverride) { - builder.Append(" tenantBrandingLogoUrl:"); + builder.Append(" tenantBrandingLogoUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantBrandingLogoUri.AbsoluteUri}'"); + builder.AppendLine($"'{TenantBrandingLogoUri.AbsoluteUri}'"); } } @@ -441,12 +441,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -467,13 +470,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationData.Serialization.cs index e6b1865a10c42..d44883096fd8d 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationData.Serialization.cs @@ -276,7 +276,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - identity = ArmApplicationManagedIdentity.DeserializeArmApplicationManagedIdentity(property.Value, options); + identity = ArmApplicationManagedIdentity.DeserializeArmApplicationManagedIdentity(property.Value); continue; } if (property.NameEquals("managedBy"u8)) @@ -290,7 +290,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value, options); + sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -396,7 +396,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - billingDetails = ArmApplicationBillingDetails.DeserializeArmApplicationBillingDetails(property0.Value, options); + billingDetails = ArmApplicationBillingDetails.DeserializeArmApplicationBillingDetails(property0.Value); continue; } if (property0.NameEquals("jitAccessPolicy"u8)) @@ -405,7 +405,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - jitAccessPolicy = ArmApplicationJitAccessPolicy.DeserializeArmApplicationJitAccessPolicy(property0.Value, options); + jitAccessPolicy = ArmApplicationJitAccessPolicy.DeserializeArmApplicationJitAccessPolicy(property0.Value); continue; } if (property0.NameEquals("publisherTenantId"u8)) @@ -426,7 +426,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item, options)); + array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item)); } authorizations = array; continue; @@ -446,7 +446,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - customerSupport = ArmApplicationPackageContact.DeserializeArmApplicationPackageContact(property0.Value, options); + customerSupport = ArmApplicationPackageContact.DeserializeArmApplicationPackageContact(property0.Value); continue; } if (property0.NameEquals("supportUrls"u8)) @@ -455,7 +455,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - supportUris = ArmApplicationPackageSupportUris.DeserializeArmApplicationPackageSupportUris(property0.Value, options); + supportUris = ArmApplicationPackageSupportUris.DeserializeArmApplicationPackageSupportUris(property0.Value); continue; } if (property0.NameEquals("artifacts"u8)) @@ -467,7 +467,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationArtifact.DeserializeArmApplicationArtifact(item, options)); + array.Add(ArmApplicationArtifact.DeserializeArmApplicationArtifact(item)); } artifacts = array; continue; @@ -478,7 +478,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } if (property0.NameEquals("updatedBy"u8)) @@ -487,7 +487,7 @@ internal static ArmApplicationData DeserializeArmApplicationData(JsonElement ele { continue; } - updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } } @@ -516,21 +516,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -538,14 +538,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -554,17 +554,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -572,12 +572,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -588,35 +588,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Plan), out propertyOverride); if (Optional.IsDefined(Plan) || hasPropertyOverride) { - builder.Append(" plan:"); + builder.Append(" plan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Plan, options, 2, false); + AppendChildObject(builder, Plan, options, 2, false, " plan: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -624,35 +624,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -660,42 +660,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -704,112 +704,112 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedResourceGroupId), out propertyOverride); if (Optional.IsDefined(ManagedResourceGroupId) || hasPropertyOverride) { - builder.Append(" managedResourceGroupId:"); + builder.Append(" managedResourceGroupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedResourceGroupId.ToString()}'"); + builder.AppendLine($"'{ManagedResourceGroupId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationDefinitionId), out propertyOverride); if (Optional.IsDefined(ApplicationDefinitionId) || hasPropertyOverride) { - builder.Append(" applicationDefinitionId:"); + builder.Append(" applicationDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ApplicationDefinitionId.ToString()}'"); + builder.AppendLine($"'{ApplicationDefinitionId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Parameters.ToString()}'"); + builder.AppendLine($"'{Parameters.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Outputs), out propertyOverride); if (Optional.IsDefined(Outputs) || hasPropertyOverride) { - builder.Append(" outputs:"); + builder.Append(" outputs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Outputs.ToString()}'"); + builder.AppendLine($"'{Outputs.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BillingDetails), out propertyOverride); if (Optional.IsDefined(BillingDetails) || hasPropertyOverride) { - builder.Append(" billingDetails:"); + builder.Append(" billingDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BillingDetails, options, 4, false); + AppendChildObject(builder, BillingDetails, options, 4, false, " billingDetails: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitAccessPolicy), out propertyOverride); if (Optional.IsDefined(JitAccessPolicy) || hasPropertyOverride) { - builder.Append(" jitAccessPolicy:"); + builder.Append(" jitAccessPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, JitAccessPolicy, options, 4, false); + AppendChildObject(builder, JitAccessPolicy, options, 4, false, " jitAccessPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublisherTenantId), out propertyOverride); if (Optional.IsDefined(PublisherTenantId) || hasPropertyOverride) { - builder.Append(" publisherTenantId:"); + builder.Append(" publisherTenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublisherTenantId.Value.ToString()}'"); + builder.AppendLine($"'{PublisherTenantId.Value.ToString()}'"); } } @@ -818,17 +818,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Authorizations.Any() || hasPropertyOverride) { - builder.Append(" authorizations:"); + builder.Append(" authorizations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Authorizations) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " authorizations: "); } builder.AppendLine(" ]"); } @@ -838,42 +838,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagementMode), out propertyOverride); if (Optional.IsDefined(ManagementMode) || hasPropertyOverride) { - builder.Append(" managementMode:"); + builder.Append(" managementMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagementMode.Value.ToString()}'"); + builder.AppendLine($"'{ManagementMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerSupport), out propertyOverride); if (Optional.IsDefined(CustomerSupport) || hasPropertyOverride) { - builder.Append(" customerSupport:"); + builder.Append(" customerSupport: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CustomerSupport, options, 4, false); + AppendChildObject(builder, CustomerSupport, options, 4, false, " customerSupport: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportUris), out propertyOverride); if (Optional.IsDefined(SupportUris) || hasPropertyOverride) { - builder.Append(" supportUrls:"); + builder.Append(" supportUrls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SupportUris, options, 4, false); + AppendChildObject(builder, SupportUris, options, 4, false, " supportUrls: "); } } @@ -882,17 +882,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Artifacts.Any() || hasPropertyOverride) { - builder.Append(" artifacts:"); + builder.Append(" artifacts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Artifacts) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " artifacts: "); } builder.AppendLine(" ]"); } @@ -902,28 +902,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedBy), out propertyOverride); if (Optional.IsDefined(CreatedBy) || hasPropertyOverride) { - builder.Append(" createdBy:"); + builder.Append(" createdBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CreatedBy, options, 4, false); + AppendChildObject(builder, CreatedBy, options, 4, false, " createdBy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedBy), out propertyOverride); if (Optional.IsDefined(UpdatedBy) || hasPropertyOverride) { - builder.Append(" updatedBy:"); + builder.Append(" updatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, UpdatedBy, options, 4, false); + AppendChildObject(builder, UpdatedBy, options, 4, false, " updatedBy: "); } } @@ -932,12 +932,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -958,13 +961,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationDefinitionData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationDefinitionData.Serialization.cs index 8d0fc54e00318..e3351448891e5 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationDefinitionData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmApplicationDefinitionData.Serialization.cs @@ -248,7 +248,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition { continue; } - sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value, options); + sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -331,7 +331,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item, options)); + array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item)); } authorizations = array; continue; @@ -345,7 +345,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationDefinitionArtifact.DeserializeArmApplicationDefinitionArtifact(item, options)); + array.Add(ArmApplicationDefinitionArtifact.DeserializeArmApplicationDefinitionArtifact(item)); } artifacts = array; continue; @@ -388,7 +388,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition { continue; } - notificationPolicy = ArmApplicationNotificationPolicy.DeserializeArmApplicationNotificationPolicy(property0.Value, options); + notificationPolicy = ArmApplicationNotificationPolicy.DeserializeArmApplicationNotificationPolicy(property0.Value); continue; } if (property0.NameEquals("lockingPolicy"u8)) @@ -397,7 +397,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition { continue; } - lockingPolicy = ArmApplicationPackageLockingPolicy.DeserializeArmApplicationPackageLockingPolicy(property0.Value, options); + lockingPolicy = ArmApplicationPackageLockingPolicy.DeserializeArmApplicationPackageLockingPolicy(property0.Value); continue; } if (property0.NameEquals("deploymentPolicy"u8)) @@ -406,7 +406,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition { continue; } - deploymentPolicy = ArmApplicationDeploymentPolicy.DeserializeArmApplicationDeploymentPolicy(property0.Value, options); + deploymentPolicy = ArmApplicationDeploymentPolicy.DeserializeArmApplicationDeploymentPolicy(property0.Value); continue; } if (property0.NameEquals("managementPolicy"u8)) @@ -415,7 +415,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition { continue; } - managementPolicy = ArmApplicationManagementPolicy.DeserializeArmApplicationManagementPolicy(property0.Value, options); + managementPolicy = ArmApplicationManagementPolicy.DeserializeArmApplicationManagementPolicy(property0.Value); continue; } if (property0.NameEquals("policies"u8)) @@ -427,7 +427,7 @@ internal static ArmApplicationDefinitionData DeserializeArmApplicationDefinition List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationPolicy.DeserializeArmApplicationPolicy(item, options)); + array.Add(ArmApplicationPolicy.DeserializeArmApplicationPolicy(item)); } policies = array; continue; @@ -458,21 +458,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -480,14 +480,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -496,17 +496,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -514,12 +514,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -530,21 +530,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -552,42 +552,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -596,35 +596,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LockLevel), out propertyOverride); if (Optional.IsDefined(LockLevel) || hasPropertyOverride) { - builder.Append(" lockLevel:"); + builder.Append(" lockLevel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LockLevel.ToSerialString()}'"); + builder.AppendLine($"'{LockLevel.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -632,15 +632,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" isEnabled:"); + builder.Append(" isEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -649,17 +649,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Authorizations.Any() || hasPropertyOverride) { - builder.Append(" authorizations:"); + builder.Append(" authorizations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Authorizations) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " authorizations: "); } builder.AppendLine(" ]"); } @@ -671,17 +671,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Artifacts.Any() || hasPropertyOverride) { - builder.Append(" artifacts:"); + builder.Append(" artifacts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Artifacts) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " artifacts: "); } builder.AppendLine(" ]"); } @@ -691,21 +691,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -713,98 +713,98 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PackageFileUri), out propertyOverride); if (Optional.IsDefined(PackageFileUri) || hasPropertyOverride) { - builder.Append(" packageFileUri:"); + builder.Append(" packageFileUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PackageFileUri.AbsoluteUri}'"); + builder.AppendLine($"'{PackageFileUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MainTemplate), out propertyOverride); if (Optional.IsDefined(MainTemplate) || hasPropertyOverride) { - builder.Append(" mainTemplate:"); + builder.Append(" mainTemplate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MainTemplate.ToString()}'"); + builder.AppendLine($"'{MainTemplate.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateUiDefinition), out propertyOverride); if (Optional.IsDefined(CreateUiDefinition) || hasPropertyOverride) { - builder.Append(" createUiDefinition:"); + builder.Append(" createUiDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateUiDefinition.ToString()}'"); + builder.AppendLine($"'{CreateUiDefinition.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotificationPolicy), out propertyOverride); if (Optional.IsDefined(NotificationPolicy) || hasPropertyOverride) { - builder.Append(" notificationPolicy:"); + builder.Append(" notificationPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, NotificationPolicy, options, 4, false); + AppendChildObject(builder, NotificationPolicy, options, 4, false, " notificationPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LockingPolicy), out propertyOverride); if (Optional.IsDefined(LockingPolicy) || hasPropertyOverride) { - builder.Append(" lockingPolicy:"); + builder.Append(" lockingPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LockingPolicy, options, 4, false); + AppendChildObject(builder, LockingPolicy, options, 4, false, " lockingPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentPolicy), out propertyOverride); if (Optional.IsDefined(DeploymentPolicy) || hasPropertyOverride) { - builder.Append(" deploymentPolicy:"); + builder.Append(" deploymentPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DeploymentPolicy, options, 4, false); + AppendChildObject(builder, DeploymentPolicy, options, 4, false, " deploymentPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagementPolicy), out propertyOverride); if (Optional.IsDefined(ManagementPolicy) || hasPropertyOverride) { - builder.Append(" managementPolicy:"); + builder.Append(" managementPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ManagementPolicy, options, 4, false); + AppendChildObject(builder, ManagementPolicy, options, 4, false, " managementPolicy: "); } } @@ -813,17 +813,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Policies.Any() || hasPropertyOverride) { - builder.Append(" policies:"); + builder.Append(" policies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Policies) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " policies: "); } builder.AppendLine(" ]"); } @@ -835,12 +835,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -861,13 +864,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentData.Serialization.cs index 05e3a3d139704..f014db714f6d6 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentData.Serialization.cs @@ -136,7 +136,7 @@ internal static ArmDeploymentData DeserializeArmDeploymentData(JsonElement eleme { continue; } - properties = ArmDeploymentPropertiesExtended.DeserializeArmDeploymentPropertiesExtended(property.Value, options); + properties = ArmDeploymentPropertiesExtended.DeserializeArmDeploymentPropertiesExtended(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -200,21 +200,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -222,14 +222,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -238,17 +238,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -256,12 +256,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -272,42 +272,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -315,12 +315,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -341,13 +344,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentScriptData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentScriptData.Serialization.cs index faf7ae3960990..27ac652b432fc 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentScriptData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ArmDeploymentScriptData.Serialization.cs @@ -112,11 +112,11 @@ internal static ArmDeploymentScriptData DeserializeArmDeploymentScriptData(JsonE { switch (discriminator.GetString()) { - case "AzureCLI": return AzureCliScript.DeserializeAzureCliScript(element, options); - case "AzurePowerShell": return AzurePowerShellScript.DeserializeAzurePowerShellScript(element, options); + case "AzureCLI": return AzureCliScript.DeserializeAzureCliScript(element); + case "AzurePowerShell": return AzurePowerShellScript.DeserializeAzurePowerShellScript(element); } } - return UnknownArmDeploymentScript.DeserializeUnknownArmDeploymentScript(element, options); + return UnknownArmDeploymentScript.DeserializeUnknownArmDeploymentScript(element); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -133,21 +133,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -155,14 +155,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -171,17 +171,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -189,12 +189,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -205,56 +205,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.ToString()}'"); + builder.AppendLine($"'{Kind.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -262,12 +262,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -288,13 +291,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/JitRequestData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/JitRequestData.Serialization.cs index 3a22beabd8611..3b0546afd8073 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/JitRequestData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/JitRequestData.Serialization.cs @@ -243,7 +243,7 @@ internal static JitRequestData DeserializeJitRequestData(JsonElement element, Mo List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(Models.JitAuthorizationPolicies.DeserializeJitAuthorizationPolicies(item, options)); + array.Add(Models.JitAuthorizationPolicies.DeserializeJitAuthorizationPolicies(item)); } jitAuthorizationPolicies = array; continue; @@ -254,7 +254,7 @@ internal static JitRequestData DeserializeJitRequestData(JsonElement element, Mo { continue; } - jitSchedulingPolicy = JitSchedulingPolicy.DeserializeJitSchedulingPolicy(property0.Value, options); + jitSchedulingPolicy = JitSchedulingPolicy.DeserializeJitSchedulingPolicy(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -281,7 +281,7 @@ internal static JitRequestData DeserializeJitRequestData(JsonElement element, Mo { continue; } - createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } if (property0.NameEquals("updatedBy"u8)) @@ -290,7 +290,7 @@ internal static JitRequestData DeserializeJitRequestData(JsonElement element, Mo { continue; } - updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -341,14 +341,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -357,17 +357,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -375,12 +375,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -391,28 +391,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -421,21 +421,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationResourceId), out propertyOverride); if (Optional.IsDefined(ApplicationResourceId) || hasPropertyOverride) { - builder.Append(" applicationResourceId:"); + builder.Append(" applicationResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApplicationResourceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApplicationResourceId}'''"); } else { - builder.AppendLine($" '{ApplicationResourceId}'"); + builder.AppendLine($"'{ApplicationResourceId}'"); } } } @@ -443,14 +443,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublisherTenantId), out propertyOverride); if (Optional.IsDefined(PublisherTenantId) || hasPropertyOverride) { - builder.Append(" publisherTenantId:"); + builder.Append(" publisherTenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublisherTenantId.Value.ToString()}'"); + builder.AppendLine($"'{PublisherTenantId.Value.ToString()}'"); } } @@ -459,17 +459,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (JitAuthorizationPolicies.Any() || hasPropertyOverride) { - builder.Append(" jitAuthorizationPolicies:"); + builder.Append(" jitAuthorizationPolicies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in JitAuthorizationPolicies) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " jitAuthorizationPolicies: "); } builder.AppendLine(" ]"); } @@ -479,70 +479,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitSchedulingPolicy), out propertyOverride); if (Optional.IsDefined(JitSchedulingPolicy) || hasPropertyOverride) { - builder.Append(" jitSchedulingPolicy:"); + builder.Append(" jitSchedulingPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, JitSchedulingPolicy, options, 4, false); + AppendChildObject(builder, JitSchedulingPolicy, options, 4, false, " jitSchedulingPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitRequestState), out propertyOverride); if (Optional.IsDefined(JitRequestState) || hasPropertyOverride) { - builder.Append(" jitRequestState:"); + builder.Append(" jitRequestState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{JitRequestState.Value.ToString()}'"); + builder.AppendLine($"'{JitRequestState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedBy), out propertyOverride); if (Optional.IsDefined(CreatedBy) || hasPropertyOverride) { - builder.Append(" createdBy:"); + builder.Append(" createdBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CreatedBy, options, 4, false); + AppendChildObject(builder, CreatedBy, options, 4, false, " createdBy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedBy), out propertyOverride); if (Optional.IsDefined(UpdatedBy) || hasPropertyOverride) { - builder.Append(" updatedBy:"); + builder.Append(" updatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, UpdatedBy, options, 4, false); + AppendChildObject(builder, UpdatedBy, options, 4, false, " updatedBy: "); } } @@ -551,12 +551,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -577,13 +580,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationArtifact.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationArtifact.Serialization.cs index e2d913e7bda8f..23f5e1eb37fa1 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationArtifact.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationArtifact.Serialization.cs @@ -117,28 +117,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToString()}'"); + builder.AppendLine($"'{Name.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } @@ -146,12 +146,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -172,13 +175,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationAuthorization.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationAuthorization.Serialization.cs index 0e6022d58cf48..32fa7099aac20 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationAuthorization.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationAuthorization.Serialization.cs @@ -109,35 +109,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.ToString()}'"); + builder.AppendLine($"'{PrincipalId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoleDefinitionId), out propertyOverride); if (Optional.IsDefined(RoleDefinitionId) || hasPropertyOverride) { - builder.Append(" roleDefinitionId:"); + builder.Append(" roleDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RoleDefinitionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RoleDefinitionId}'''"); } else { - builder.AppendLine($" '{RoleDefinitionId}'"); + builder.AppendLine($"'{RoleDefinitionId}'"); } } } @@ -146,12 +146,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -172,13 +175,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationBillingDetails.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationBillingDetails.Serialization.cs index ed7db2530a0e2..dea810360235a 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationBillingDetails.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationBillingDetails.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceUsageId), out propertyOverride); if (Optional.IsDefined(ResourceUsageId) || hasPropertyOverride) { - builder.Append(" resourceUsageId:"); + builder.Append(" resourceUsageId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceUsageId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceUsageId}'''"); } else { - builder.AppendLine($" '{ResourceUsageId}'"); + builder.AppendLine($"'{ResourceUsageId}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionArtifact.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionArtifact.Serialization.cs index b4f039b94ea39..d5914118eaea3 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionArtifact.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionArtifact.Serialization.cs @@ -117,28 +117,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToString()}'"); + builder.AppendLine($"'{Name.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } @@ -146,12 +146,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -172,13 +175,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionListResult.Serialization.cs index ab282899e9c3c..104555393ef8f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDefinitionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ArmApplicationDefinitionListResult DeserializeArmApplicationDefi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmApplicationDefinitionData.DeserializeArmApplicationDefinitionData(item, options)); + array.Add(ArmApplicationDefinitionData.DeserializeArmApplicationDefinitionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDeploymentPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDeploymentPolicy.Serialization.cs index b904c085affec..46fa2ec7e6b4b 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDeploymentPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDeploymentPolicy.Serialization.cs @@ -101,14 +101,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentMode), out propertyOverride); if (Optional.IsDefined(DeploymentMode) || hasPropertyOverride) { - builder.Append(" deploymentMode:"); + builder.Append(" deploymentMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DeploymentMode.ToString()}'"); + builder.AppendLine($"'{DeploymentMode.ToString()}'"); } } @@ -116,12 +116,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -142,13 +145,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDetails.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDetails.Serialization.cs index e03e21ef1e392..35fbeee765bb6 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDetails.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationDetails.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectId), out propertyOverride); if (Optional.IsDefined(ObjectId) || hasPropertyOverride) { - builder.Append(" oid:"); + builder.Append(" oid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ObjectId.Value.ToString()}'"); + builder.AppendLine($"'{ObjectId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Puid), out propertyOverride); if (Optional.IsDefined(Puid) || hasPropertyOverride) { - builder.Append(" puid:"); + builder.Append(" puid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Puid.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Puid}'''"); } else { - builder.AppendLine($" '{Puid}'"); + builder.AppendLine($"'{Puid}'"); } } } @@ -170,14 +170,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationId), out propertyOverride); if (Optional.IsDefined(ApplicationId) || hasPropertyOverride) { - builder.Append(" applicationId:"); + builder.Append(" applicationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ApplicationId.Value.ToString()}'"); + builder.AppendLine($"'{ApplicationId.Value.ToString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationJitAccessPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationJitAccessPolicy.Serialization.cs index 6fce2e7176dc8..b5b4046f6ec23 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationJitAccessPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationJitAccessPolicy.Serialization.cs @@ -120,7 +120,7 @@ internal static ArmApplicationJitAccessPolicy DeserializeArmApplicationJitAccess List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(JitApprover.DeserializeJitApprover(item, options)); + array.Add(JitApprover.DeserializeJitApprover(item)); } jitApprovers = array; continue; @@ -157,29 +157,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitAccessEnabled), out propertyOverride); if (Optional.IsDefined(JitAccessEnabled) || hasPropertyOverride) { - builder.Append(" jitAccessEnabled:"); + builder.Append(" jitAccessEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = JitAccessEnabled == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitApprovalMode), out propertyOverride); if (Optional.IsDefined(JitApprovalMode) || hasPropertyOverride) { - builder.Append(" jitApprovalMode:"); + builder.Append(" jitApprovalMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{JitApprovalMode.Value.ToString()}'"); + builder.AppendLine($"'{JitApprovalMode.Value.ToString()}'"); } } @@ -188,17 +188,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (JitApprovers.Any() || hasPropertyOverride) { - builder.Append(" jitApprovers:"); + builder.Append(" jitApprovers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in JitApprovers) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " jitApprovers: "); } builder.AppendLine(" ]"); } @@ -208,15 +208,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumJitAccessDuration), out propertyOverride); if (Optional.IsDefined(MaximumJitAccessDuration) || hasPropertyOverride) { - builder.Append(" maximumJitAccessDuration:"); + builder.Append(" maximumJitAccessDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(MaximumJitAccessDuration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } @@ -224,12 +224,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -250,13 +253,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationListResult.Serialization.cs index e42e35780e1b7..f086f73e2074f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ArmApplicationListResult DeserializeArmApplicationListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmApplicationData.DeserializeArmApplicationData(item, options)); + array.Add(ArmApplicationData.DeserializeArmApplicationData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagedIdentity.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagedIdentity.Serialization.cs index fa996fb7f9fe6..cf65288925cb2 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagedIdentity.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagedIdentity.Serialization.cs @@ -137,7 +137,7 @@ internal static ArmApplicationManagedIdentity DeserializeArmApplicationManagedId Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(property0.Name, ArmApplicationUserAssignedIdentity.DeserializeArmApplicationUserAssignedIdentity(property0.Value, options)); + dictionary.Add(property0.Name, ArmApplicationUserAssignedIdentity.DeserializeArmApplicationUserAssignedIdentity(property0.Value)); } userAssignedIdentities = dictionary; continue; @@ -165,28 +165,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -195,18 +195,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserAssignedIdentities.Any() || hasPropertyOverride) { - builder.Append(" userAssignedIdentities:"); + builder.Append(" userAssignedIdentities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in UserAssignedIdentities) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " userAssignedIdentities: "); } builder.AppendLine(" }"); } @@ -217,12 +217,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -243,13 +246,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagementPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagementPolicy.Serialization.cs index 27538a165c730..da0d5641584a3 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagementPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationManagementPolicy.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mode), out propertyOverride); if (Optional.IsDefined(Mode) || hasPropertyOverride) { - builder.Append(" mode:"); + builder.Append(" mode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Mode.Value.ToString()}'"); + builder.AppendLine($"'{Mode.Value.ToString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationEndpoint.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationEndpoint.Serialization.cs index 4647b5413f2d9..84b75b35b9b9a 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationEndpoint.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationEndpoint.Serialization.cs @@ -101,14 +101,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } @@ -116,12 +116,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -142,13 +145,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationPolicy.Serialization.cs index b7421d874af91..a4aa2df5c96b5 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationNotificationPolicy.Serialization.cs @@ -84,7 +84,7 @@ internal static ArmApplicationNotificationPolicy DeserializeArmApplicationNotifi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmApplicationNotificationEndpoint.DeserializeArmApplicationNotificationEndpoint(item, options)); + array.Add(ArmApplicationNotificationEndpoint.DeserializeArmApplicationNotificationEndpoint(item)); } notificationEndpoints = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NotificationEndpoints.Any() || hasPropertyOverride) { - builder.Append(" notificationEndpoints:"); + builder.Append(" notificationEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NotificationEndpoints) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " notificationEndpoints: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageContact.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageContact.Serialization.cs index 4919081ce3b67..6fd7803315022 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageContact.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageContact.Serialization.cs @@ -120,21 +120,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactName), out propertyOverride); if (Optional.IsDefined(ContactName) || hasPropertyOverride) { - builder.Append(" contactName:"); + builder.Append(" contactName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContactName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContactName}'''"); } else { - builder.AppendLine($" '{ContactName}'"); + builder.AppendLine($"'{ContactName}'"); } } } @@ -142,21 +142,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Email), out propertyOverride); if (Optional.IsDefined(Email) || hasPropertyOverride) { - builder.Append(" email:"); + builder.Append(" email: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Email.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Email}'''"); } else { - builder.AppendLine($" '{Email}'"); + builder.AppendLine($"'{Email}'"); } } } @@ -164,21 +164,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Phone), out propertyOverride); if (Optional.IsDefined(Phone) || hasPropertyOverride) { - builder.Append(" phone:"); + builder.Append(" phone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Phone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Phone}'''"); } else { - builder.AppendLine($" '{Phone}'"); + builder.AppendLine($"'{Phone}'"); } } } @@ -187,12 +187,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -213,13 +216,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageLockingPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageLockingPolicy.Serialization.cs index 0de5326bcbf0f..56864b21fecc8 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageLockingPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageLockingPolicy.Serialization.cs @@ -146,14 +146,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedActions.Any() || hasPropertyOverride) { - builder.Append(" allowedActions:"); + builder.Append(" allowedActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedActions) { if (item == null) @@ -181,14 +181,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedDataActions.Any() || hasPropertyOverride) { - builder.Append(" allowedDataActions:"); + builder.Append(" allowedDataActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedDataActions) { if (item == null) @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageSupportUris.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageSupportUris.Serialization.cs index fc1cb57c31e04..5e2832f76c6a9 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageSupportUris.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPackageSupportUris.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzurePublicCloudUri), out propertyOverride); if (Optional.IsDefined(AzurePublicCloudUri) || hasPropertyOverride) { - builder.Append(" publicAzure:"); + builder.Append(" publicAzure: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AzurePublicCloudUri.AbsoluteUri}'"); + builder.AppendLine($"'{AzurePublicCloudUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureGovernmentUri), out propertyOverride); if (Optional.IsDefined(AzureGovernmentUri) || hasPropertyOverride) { - builder.Append(" governmentCloud:"); + builder.Append(" governmentCloud: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AzureGovernmentUri.AbsoluteUri}'"); + builder.AppendLine($"'{AzureGovernmentUri.AbsoluteUri}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPatch.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPatch.Serialization.cs index 53d318659e830..c289aaa6ca676 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPatch.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPatch.Serialization.cs @@ -278,7 +278,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - identity = ArmApplicationManagedIdentity.DeserializeArmApplicationManagedIdentity(property.Value, options); + identity = ArmApplicationManagedIdentity.DeserializeArmApplicationManagedIdentity(property.Value); continue; } if (property.NameEquals("managedBy"u8)) @@ -292,7 +292,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value, options); + sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -398,7 +398,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - billingDetails = ArmApplicationBillingDetails.DeserializeArmApplicationBillingDetails(property0.Value, options); + billingDetails = ArmApplicationBillingDetails.DeserializeArmApplicationBillingDetails(property0.Value); continue; } if (property0.NameEquals("jitAccessPolicy"u8)) @@ -407,7 +407,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - jitAccessPolicy = ArmApplicationJitAccessPolicy.DeserializeArmApplicationJitAccessPolicy(property0.Value, options); + jitAccessPolicy = ArmApplicationJitAccessPolicy.DeserializeArmApplicationJitAccessPolicy(property0.Value); continue; } if (property0.NameEquals("publisherTenantId"u8)) @@ -428,7 +428,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item, options)); + array.Add(ArmApplicationAuthorization.DeserializeArmApplicationAuthorization(item)); } authorizations = array; continue; @@ -448,7 +448,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - customerSupport = ArmApplicationPackageContact.DeserializeArmApplicationPackageContact(property0.Value, options); + customerSupport = ArmApplicationPackageContact.DeserializeArmApplicationPackageContact(property0.Value); continue; } if (property0.NameEquals("supportUrls"u8)) @@ -457,7 +457,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - supportUris = ArmApplicationPackageSupportUris.DeserializeArmApplicationPackageSupportUris(property0.Value, options); + supportUris = ArmApplicationPackageSupportUris.DeserializeArmApplicationPackageSupportUris(property0.Value); continue; } if (property0.NameEquals("artifacts"u8)) @@ -469,7 +469,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ArmApplicationArtifact.DeserializeArmApplicationArtifact(item, options)); + array.Add(ArmApplicationArtifact.DeserializeArmApplicationArtifact(item)); } artifacts = array; continue; @@ -480,7 +480,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + createdBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } if (property0.NameEquals("updatedBy"u8)) @@ -489,7 +489,7 @@ internal static ArmApplicationPatch DeserializeArmApplicationPatch(JsonElement e { continue; } - updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value, options); + updatedBy = ArmApplicationDetails.DeserializeArmApplicationDetails(property0.Value); continue; } } @@ -518,21 +518,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -540,14 +540,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -556,17 +556,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -574,12 +574,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -590,35 +590,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Plan), out propertyOverride); if (Optional.IsDefined(Plan) || hasPropertyOverride) { - builder.Append(" plan:"); + builder.Append(" plan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Plan, options, 2, false); + AppendChildObject(builder, Plan, options, 2, false, " plan: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -626,35 +626,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -662,42 +662,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -706,112 +706,112 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedResourceGroupId), out propertyOverride); if (Optional.IsDefined(ManagedResourceGroupId) || hasPropertyOverride) { - builder.Append(" managedResourceGroupId:"); + builder.Append(" managedResourceGroupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedResourceGroupId.ToString()}'"); + builder.AppendLine($"'{ManagedResourceGroupId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationDefinitionId), out propertyOverride); if (Optional.IsDefined(ApplicationDefinitionId) || hasPropertyOverride) { - builder.Append(" applicationDefinitionId:"); + builder.Append(" applicationDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ApplicationDefinitionId.ToString()}'"); + builder.AppendLine($"'{ApplicationDefinitionId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Parameters.ToString()}'"); + builder.AppendLine($"'{Parameters.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Outputs), out propertyOverride); if (Optional.IsDefined(Outputs) || hasPropertyOverride) { - builder.Append(" outputs:"); + builder.Append(" outputs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Outputs.ToString()}'"); + builder.AppendLine($"'{Outputs.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BillingDetails), out propertyOverride); if (Optional.IsDefined(BillingDetails) || hasPropertyOverride) { - builder.Append(" billingDetails:"); + builder.Append(" billingDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BillingDetails, options, 4, false); + AppendChildObject(builder, BillingDetails, options, 4, false, " billingDetails: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JitAccessPolicy), out propertyOverride); if (Optional.IsDefined(JitAccessPolicy) || hasPropertyOverride) { - builder.Append(" jitAccessPolicy:"); + builder.Append(" jitAccessPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, JitAccessPolicy, options, 4, false); + AppendChildObject(builder, JitAccessPolicy, options, 4, false, " jitAccessPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublisherTenantId), out propertyOverride); if (Optional.IsDefined(PublisherTenantId) || hasPropertyOverride) { - builder.Append(" publisherTenantId:"); + builder.Append(" publisherTenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublisherTenantId.Value.ToString()}'"); + builder.AppendLine($"'{PublisherTenantId.Value.ToString()}'"); } } @@ -820,17 +820,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Authorizations.Any() || hasPropertyOverride) { - builder.Append(" authorizations:"); + builder.Append(" authorizations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Authorizations) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " authorizations: "); } builder.AppendLine(" ]"); } @@ -840,42 +840,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagementMode), out propertyOverride); if (Optional.IsDefined(ManagementMode) || hasPropertyOverride) { - builder.Append(" managementMode:"); + builder.Append(" managementMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagementMode.Value.ToString()}'"); + builder.AppendLine($"'{ManagementMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerSupport), out propertyOverride); if (Optional.IsDefined(CustomerSupport) || hasPropertyOverride) { - builder.Append(" customerSupport:"); + builder.Append(" customerSupport: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CustomerSupport, options, 4, false); + AppendChildObject(builder, CustomerSupport, options, 4, false, " customerSupport: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportUris), out propertyOverride); if (Optional.IsDefined(SupportUris) || hasPropertyOverride) { - builder.Append(" supportUrls:"); + builder.Append(" supportUrls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SupportUris, options, 4, false); + AppendChildObject(builder, SupportUris, options, 4, false, " supportUrls: "); } } @@ -884,17 +884,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Artifacts.Any() || hasPropertyOverride) { - builder.Append(" artifacts:"); + builder.Append(" artifacts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Artifacts) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " artifacts: "); } builder.AppendLine(" ]"); } @@ -904,28 +904,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedBy), out propertyOverride); if (Optional.IsDefined(CreatedBy) || hasPropertyOverride) { - builder.Append(" createdBy:"); + builder.Append(" createdBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CreatedBy, options, 4, false); + AppendChildObject(builder, CreatedBy, options, 4, false, " createdBy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedBy), out propertyOverride); if (Optional.IsDefined(UpdatedBy) || hasPropertyOverride) { - builder.Append(" updatedBy:"); + builder.Append(" updatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, UpdatedBy, options, 4, false); + AppendChildObject(builder, UpdatedBy, options, 4, false, " updatedBy: "); } } @@ -934,12 +934,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -960,13 +963,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPolicy.Serialization.cs index b5d074e6fdfd6..4de57b9583e7f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationPolicy.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyDefinitionId), out propertyOverride); if (Optional.IsDefined(PolicyDefinitionId) || hasPropertyOverride) { - builder.Append(" policyDefinitionId:"); + builder.Append(" policyDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyDefinitionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyDefinitionId}'''"); } else { - builder.AppendLine($" '{PolicyDefinitionId}'"); + builder.AppendLine($"'{PolicyDefinitionId}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Parameters.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Parameters}'''"); } else { - builder.AppendLine($" '{Parameters}'"); + builder.AppendLine($"'{Parameters}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationResourceData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationResourceData.Serialization.cs index e95e5db285031..4f47c99aa7904 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationResourceData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationResourceData.Serialization.cs @@ -134,7 +134,7 @@ internal static ArmApplicationResourceData DeserializeArmApplicationResourceData { continue; } - sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value, options); + sku = ArmApplicationSku.DeserializeArmApplicationSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -241,17 +241,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -259,12 +259,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -275,21 +275,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -297,42 +297,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationSku.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationSku.Serialization.cs index da03befa3b5cc..57e5b67f3f96a 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationSku.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationSku.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -182,21 +182,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -226,21 +226,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -248,21 +248,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Model), out propertyOverride); if (Optional.IsDefined(Model) || hasPropertyOverride) { - builder.Append(" model:"); + builder.Append(" model: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Model.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Model}'''"); } else { - builder.AppendLine($" '{Model}'"); + builder.AppendLine($"'{Model}'"); } } } @@ -270,14 +270,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Capacity.Value}"); + builder.AppendLine($"{Capacity.Value}"); } } @@ -285,12 +285,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -311,13 +314,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationUserAssignedIdentity.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationUserAssignedIdentity.Serialization.cs index a414ec49cb644..ab5473e6aae05 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationUserAssignedIdentity.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmApplicationUserAssignedIdentity.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDependency.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDependency.Serialization.cs index f5fe0d8a01190..e7d22110fb06a 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDependency.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDependency.Serialization.cs @@ -109,7 +109,7 @@ internal static ArmDependency DeserializeArmDependency(JsonElement element, Mode List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BasicArmDependency.DeserializeBasicArmDependency(item, options)); + array.Add(BasicArmDependency.DeserializeBasicArmDependency(item)); } dependsOn = array; continue; @@ -158,17 +158,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DependsOn.Any() || hasPropertyOverride) { - builder.Append(" dependsOn:"); + builder.Append(" dependsOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DependsOn) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " dependsOn: "); } builder.AppendLine(" ]"); } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -200,35 +200,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceType.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -237,12 +237,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -263,13 +266,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentContent.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentContent.Serialization.cs index e9974d035628f..c4b838091bab8 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentContent.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentContent.Serialization.cs @@ -100,7 +100,7 @@ internal static ArmDeploymentContent DeserializeArmDeploymentContent(JsonElement } if (property.NameEquals("properties"u8)) { - properties = ArmDeploymentProperties.DeserializeArmDeploymentProperties(property.Value, options); + properties = ArmDeploymentProperties.DeserializeArmDeploymentProperties(property.Value); continue; } if (property.NameEquals("tags"u8)) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentExportResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentExportResult.Serialization.cs index 9293123fb6139..f627fe469912b 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentExportResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentExportResult.Serialization.cs @@ -115,14 +115,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); if (Optional.IsDefined(Template) || hasPropertyOverride) { - builder.Append(" template:"); + builder.Append(" template: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Template.ToString()}'"); + builder.AppendLine($"'{Template.ToString()}'"); } } @@ -130,12 +130,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -156,13 +159,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentListResult.Serialization.cs index 410260c248ac1..e618e05f9446e 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ArmDeploymentListResult DeserializeArmDeploymentListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmDeploymentData.DeserializeArmDeploymentData(item, options)); + array.Add(ArmDeploymentData.DeserializeArmDeploymentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperation.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperation.Serialization.cs index b04d3a9c75245..63c024cf803c0 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperation.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperation.Serialization.cs @@ -104,7 +104,7 @@ internal static ArmDeploymentOperation DeserializeArmDeploymentOperation(JsonEle { continue; } - properties = ArmDeploymentOperationProperties.DeserializeArmDeploymentOperationProperties(property.Value, options); + properties = ArmDeploymentOperationProperties.DeserializeArmDeploymentOperationProperties(property.Value); continue; } if (options.Format != "W") @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationId), out propertyOverride); if (Optional.IsDefined(OperationId) || hasPropertyOverride) { - builder.Append(" operationId:"); + builder.Append(" operationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationId}'''"); } else { - builder.AppendLine($" '{OperationId}'"); + builder.AppendLine($"'{OperationId}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationProperties.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationProperties.Serialization.cs index 866e6d42229be..25e1e19db0304 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationProperties.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationProperties.Serialization.cs @@ -186,7 +186,7 @@ internal static ArmDeploymentOperationProperties DeserializeArmDeploymentOperati statusMessage = null; continue; } - statusMessage = StatusMessage.DeserializeStatusMessage(property.Value, options); + statusMessage = StatusMessage.DeserializeStatusMessage(property.Value); continue; } if (property.NameEquals("targetResource"u8)) @@ -195,7 +195,7 @@ internal static ArmDeploymentOperationProperties DeserializeArmDeploymentOperati { continue; } - targetResource = TargetResource.DeserializeTargetResource(property.Value, options); + targetResource = TargetResource.DeserializeTargetResource(property.Value); continue; } if (property.NameEquals("request"u8)) @@ -204,7 +204,7 @@ internal static ArmDeploymentOperationProperties DeserializeArmDeploymentOperati { continue; } - request = HttpMessage.DeserializeHttpMessage(property.Value, options); + request = HttpMessage.DeserializeHttpMessage(property.Value); continue; } if (property.NameEquals("response"u8)) @@ -213,7 +213,7 @@ internal static ArmDeploymentOperationProperties DeserializeArmDeploymentOperati { continue; } - response = HttpMessage.DeserializeHttpMessage(property.Value, options); + response = HttpMessage.DeserializeHttpMessage(property.Value); continue; } if (options.Format != "W") @@ -239,35 +239,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningOperation), out propertyOverride); if (Optional.IsDefined(ProvisioningOperation) || hasPropertyOverride) { - builder.Append(" provisioningOperation:"); + builder.Append(" provisioningOperation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningOperation.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningOperation.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -275,51 +275,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Duration), out propertyOverride); if (Optional.IsDefined(Duration) || hasPropertyOverride) { - builder.Append(" duration:"); + builder.Append(" duration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Duration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceRequestId), out propertyOverride); if (Optional.IsDefined(ServiceRequestId) || hasPropertyOverride) { - builder.Append(" serviceRequestId:"); + builder.Append(" serviceRequestId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceRequestId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceRequestId}'''"); } else { - builder.AppendLine($" '{ServiceRequestId}'"); + builder.AppendLine($"'{ServiceRequestId}'"); } } } @@ -327,21 +327,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusCode), out propertyOverride); if (Optional.IsDefined(StatusCode) || hasPropertyOverride) { - builder.Append(" statusCode:"); + builder.Append(" statusCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StatusCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StatusCode}'''"); } else { - builder.AppendLine($" '{StatusCode}'"); + builder.AppendLine($"'{StatusCode}'"); } } } @@ -349,56 +349,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusMessage), out propertyOverride); if (Optional.IsDefined(StatusMessage) || hasPropertyOverride) { - builder.Append(" statusMessage:"); + builder.Append(" statusMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StatusMessage, options, 2, false); + AppendChildObject(builder, StatusMessage, options, 2, false, " statusMessage: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetResource), out propertyOverride); if (Optional.IsDefined(TargetResource) || hasPropertyOverride) { - builder.Append(" targetResource:"); + builder.Append(" targetResource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TargetResource, options, 2, false); + AppendChildObject(builder, TargetResource, options, 2, false, " targetResource: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Request), out propertyOverride); if (Optional.IsDefined(Request) || hasPropertyOverride) { - builder.Append(" request:"); + builder.Append(" request: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Request, options, 2, false); + AppendChildObject(builder, Request, options, 2, false, " request: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Response), out propertyOverride); if (Optional.IsDefined(Response) || hasPropertyOverride) { - builder.Append(" response:"); + builder.Append(" response: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Response, options, 2, false); + AppendChildObject(builder, Response, options, 2, false, " response: "); } } @@ -406,12 +406,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -432,13 +435,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationsListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationsListResult.Serialization.cs index eec502125656b..04369fa1b1aca 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationsListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentOperationsListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ArmDeploymentOperationsListResult DeserializeArmDeploymentOperat List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmDeploymentOperation.DeserializeArmDeploymentOperation(item, options)); + array.Add(ArmDeploymentOperation.DeserializeArmDeploymentOperation(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentParametersLink.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentParametersLink.Serialization.cs index c07766756ae41..ff17c5b8629f2 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentParametersLink.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentParametersLink.Serialization.cs @@ -112,35 +112,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentVersion), out propertyOverride); if (Optional.IsDefined(ContentVersion) || hasPropertyOverride) { - builder.Append(" contentVersion:"); + builder.Append(" contentVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentVersion}'''"); } else { - builder.AppendLine($" '{ContentVersion}'"); + builder.AppendLine($"'{ContentVersion}'"); } } } @@ -149,12 +149,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -175,13 +178,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentProperties.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentProperties.Serialization.cs index 11bae197905af..5991a863ce7ab 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentProperties.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentProperties.Serialization.cs @@ -142,7 +142,7 @@ internal static ArmDeploymentProperties DeserializeArmDeploymentProperties(JsonE { continue; } - templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value, options); + templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value); continue; } if (property.NameEquals("parameters"u8)) @@ -160,7 +160,7 @@ internal static ArmDeploymentProperties DeserializeArmDeploymentProperties(JsonE { continue; } - parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value, options); + parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value); continue; } if (property.NameEquals("mode"u8)) @@ -174,7 +174,7 @@ internal static ArmDeploymentProperties DeserializeArmDeploymentProperties(JsonE { continue; } - debugSetting = DebugSetting.DeserializeDebugSetting(property.Value, options); + debugSetting = DebugSetting.DeserializeDebugSetting(property.Value); continue; } if (property.NameEquals("onErrorDeployment"u8)) @@ -183,7 +183,7 @@ internal static ArmDeploymentProperties DeserializeArmDeploymentProperties(JsonE { continue; } - onErrorDeployment = ErrorDeployment.DeserializeErrorDeployment(property.Value, options); + onErrorDeployment = ErrorDeployment.DeserializeErrorDeployment(property.Value); continue; } if (property.NameEquals("expressionEvaluationOptions"u8)) @@ -192,7 +192,7 @@ internal static ArmDeploymentProperties DeserializeArmDeploymentProperties(JsonE { continue; } - expressionEvaluationOptions = ExpressionEvaluationOptions.DeserializeExpressionEvaluationOptions(property.Value, options); + expressionEvaluationOptions = ExpressionEvaluationOptions.DeserializeExpressionEvaluationOptions(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentPropertiesExtended.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentPropertiesExtended.Serialization.cs index 8e044efb997ee..59042a6312080 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentPropertiesExtended.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentPropertiesExtended.Serialization.cs @@ -273,7 +273,7 @@ internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentProperti List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmDependency.DeserializeArmDependency(item, options)); + array.Add(ArmDependency.DeserializeArmDependency(item)); } dependencies = array; continue; @@ -284,7 +284,7 @@ internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentProperti { continue; } - templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value, options); + templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value); continue; } if (property.NameEquals("parameters"u8)) @@ -302,7 +302,7 @@ internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentProperti { continue; } - parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value, options); + parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value); continue; } if (property.NameEquals("mode"u8)) @@ -320,7 +320,7 @@ internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentProperti { continue; } - debugSetting = DebugSetting.DeserializeDebugSetting(property.Value, options); + debugSetting = DebugSetting.DeserializeDebugSetting(property.Value); continue; } if (property.NameEquals("onErrorDeployment"u8)) @@ -329,7 +329,7 @@ internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentProperti { continue; } - onErrorDeployment = ErrorDeploymentExtended.DeserializeErrorDeploymentExtended(property.Value, options); + onErrorDeployment = ErrorDeploymentExtended.DeserializeErrorDeploymentExtended(property.Value); continue; } if (property.NameEquals("templateHash"u8)) @@ -397,35 +397,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CorrelationId), out propertyOverride); if (Optional.IsDefined(CorrelationId) || hasPropertyOverride) { - builder.Append(" correlationId:"); + builder.Append(" correlationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CorrelationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CorrelationId}'''"); } else { - builder.AppendLine($" '{CorrelationId}'"); + builder.AppendLine($"'{CorrelationId}'"); } } } @@ -433,44 +433,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Duration), out propertyOverride); if (Optional.IsDefined(Duration) || hasPropertyOverride) { - builder.Append(" duration:"); + builder.Append(" duration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Duration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Outputs), out propertyOverride); if (Optional.IsDefined(Outputs) || hasPropertyOverride) { - builder.Append(" outputs:"); + builder.Append(" outputs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Outputs.ToString()}'"); + builder.AppendLine($"'{Outputs.ToString()}'"); } } @@ -479,17 +479,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Providers.Any() || hasPropertyOverride) { - builder.Append(" providers:"); + builder.Append(" providers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Providers) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " providers: "); } builder.AppendLine(" ]"); } @@ -501,17 +501,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Dependencies.Any() || hasPropertyOverride) { - builder.Append(" dependencies:"); + builder.Append(" dependencies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Dependencies) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " dependencies: "); } builder.AppendLine(" ]"); } @@ -521,105 +521,105 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateLink), out propertyOverride); if (Optional.IsDefined(TemplateLink) || hasPropertyOverride) { - builder.Append(" templateLink:"); + builder.Append(" templateLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TemplateLink, options, 2, false); + AppendChildObject(builder, TemplateLink, options, 2, false, " templateLink: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Parameters.ToString()}'"); + builder.AppendLine($"'{Parameters.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ParametersLink), out propertyOverride); if (Optional.IsDefined(ParametersLink) || hasPropertyOverride) { - builder.Append(" parametersLink:"); + builder.Append(" parametersLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ParametersLink, options, 2, false); + AppendChildObject(builder, ParametersLink, options, 2, false, " parametersLink: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mode), out propertyOverride); if (Optional.IsDefined(Mode) || hasPropertyOverride) { - builder.Append(" mode:"); + builder.Append(" mode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Mode.Value.ToSerialString()}'"); + builder.AppendLine($"'{Mode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DebugSetting), out propertyOverride); if (Optional.IsDefined(DebugSetting) || hasPropertyOverride) { - builder.Append(" debugSetting:"); + builder.Append(" debugSetting: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DebugSetting, options, 2, false); + AppendChildObject(builder, DebugSetting, options, 2, false, " debugSetting: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDeployment), out propertyOverride); if (Optional.IsDefined(ErrorDeployment) || hasPropertyOverride) { - builder.Append(" onErrorDeployment:"); + builder.Append(" onErrorDeployment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ErrorDeployment, options, 2, false); + AppendChildObject(builder, ErrorDeployment, options, 2, false, " onErrorDeployment: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateHash), out propertyOverride); if (Optional.IsDefined(TemplateHash) || hasPropertyOverride) { - builder.Append(" templateHash:"); + builder.Append(" templateHash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TemplateHash.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TemplateHash}'''"); } else { - builder.AppendLine($" '{TemplateHash}'"); + builder.AppendLine($"'{TemplateHash}'"); } } } @@ -629,17 +629,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (OutputResources.Any() || hasPropertyOverride) { - builder.Append(" outputResources:"); + builder.Append(" outputResources: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in OutputResources) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " outputResources: "); } builder.AppendLine(" ]"); } @@ -651,17 +651,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ValidatedResources.Any() || hasPropertyOverride) { - builder.Append(" validatedResources:"); + builder.Append(" validatedResources: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ValidatedResources) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " validatedResources: "); } builder.AppendLine(" ]"); } @@ -671,14 +671,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -686,12 +686,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -712,13 +715,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptListResult.Serialization.cs index 6258eecc9c28b..805a45c833dec 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ArmDeploymentScriptListResult DeserializeArmDeploymentScriptList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmDeploymentScriptData.DeserializeArmDeploymentScriptData(item, options)); + array.Add(ArmDeploymentScriptData.DeserializeArmDeploymentScriptData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptManagedIdentity.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptManagedIdentity.Serialization.cs index 7d70159ab9bd6..0cc1ed4795e6f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptManagedIdentity.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptManagedIdentity.Serialization.cs @@ -151,14 +151,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -167,18 +167,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserAssignedIdentities.Any() || hasPropertyOverride) { - builder.Append(" userAssignedIdentities:"); + builder.Append(" userAssignedIdentities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in UserAssignedIdentities) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " userAssignedIdentities: "); } builder.AppendLine(" }"); } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPatch.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPatch.Serialization.cs index 11770e4631114..ef4a5e1f142f9 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPatch.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPatch.Serialization.cs @@ -169,21 +169,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,17 +193,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -211,12 +211,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -256,12 +256,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -282,13 +285,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPropertiesBase.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPropertiesBase.Serialization.cs index 2d67c0a3ec23a..3220d2425fa24 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPropertiesBase.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentScriptPropertiesBase.Serialization.cs @@ -117,7 +117,7 @@ internal static ArmDeploymentScriptPropertiesBase DeserializeArmDeploymentScript { continue; } - containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property.Value, options); + containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property.Value); continue; } if (property.NameEquals("storageAccountSettings"u8)) @@ -126,7 +126,7 @@ internal static ArmDeploymentScriptPropertiesBase DeserializeArmDeploymentScript { continue; } - storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property.Value, options); + storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property.Value); continue; } if (property.NameEquals("cleanupPreference"u8)) @@ -153,7 +153,7 @@ internal static ArmDeploymentScriptPropertiesBase DeserializeArmDeploymentScript { continue; } - status = ScriptStatus.DeserializeScriptStatus(property.Value, options); + status = ScriptStatus.DeserializeScriptStatus(property.Value); continue; } if (property.NameEquals("outputs"u8)) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentTemplateLink.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentTemplateLink.Serialization.cs index 4f083e7ee8f1e..2077170e2a684 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentTemplateLink.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentTemplateLink.Serialization.cs @@ -152,35 +152,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RelativePath), out propertyOverride); if (Optional.IsDefined(RelativePath) || hasPropertyOverride) { - builder.Append(" relativePath:"); + builder.Append(" relativePath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RelativePath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RelativePath}'''"); } else { - builder.AppendLine($" '{RelativePath}'"); + builder.AppendLine($"'{RelativePath}'"); } } } @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentVersion), out propertyOverride); if (Optional.IsDefined(ContentVersion) || hasPropertyOverride) { - builder.Append(" contentVersion:"); + builder.Append(" contentVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentVersion}'''"); } else { - builder.AppendLine($" '{ContentVersion}'"); + builder.AppendLine($"'{ContentVersion}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryString), out propertyOverride); if (Optional.IsDefined(QueryString) || hasPropertyOverride) { - builder.Append(" queryString:"); + builder.Append(" queryString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueryString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueryString}'''"); } else { - builder.AppendLine($" '{QueryString}'"); + builder.AppendLine($"'{QueryString}'"); } } } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentValidateResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentValidateResult.Serialization.cs index 09ea300e35076..bfaf26059da15 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentValidateResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentValidateResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ArmDeploymentValidateResult DeserializeArmDeploymentValidateResu { continue; } - properties = ArmDeploymentPropertiesExtended.DeserializeArmDeploymentPropertiesExtended(property.Value, options); + properties = ArmDeploymentPropertiesExtended.DeserializeArmDeploymentPropertiesExtended(property.Value); continue; } if (options.Format != "W") @@ -124,28 +124,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfContent.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfContent.Serialization.cs index 2df23648669be..dca7116633606 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfContent.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfContent.Serialization.cs @@ -88,7 +88,7 @@ internal static ArmDeploymentWhatIfContent DeserializeArmDeploymentWhatIfContent } if (property.NameEquals("properties"u8)) { - properties = ArmDeploymentWhatIfProperties.DeserializeArmDeploymentWhatIfProperties(property.Value, options); + properties = ArmDeploymentWhatIfProperties.DeserializeArmDeploymentWhatIfProperties(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfProperties.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfProperties.Serialization.cs index a37ccf9a86e18..e9bd0b465760d 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfProperties.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ArmDeploymentWhatIfProperties.Serialization.cs @@ -139,7 +139,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - whatIfSettings = ArmDeploymentWhatIfSettings.DeserializeArmDeploymentWhatIfSettings(property.Value, options); + whatIfSettings = ArmDeploymentWhatIfSettings.DeserializeArmDeploymentWhatIfSettings(property.Value); continue; } if (property.NameEquals("template"u8)) @@ -157,7 +157,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value, options); + templateLink = ArmDeploymentTemplateLink.DeserializeArmDeploymentTemplateLink(property.Value); continue; } if (property.NameEquals("parameters"u8)) @@ -175,7 +175,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value, options); + parametersLink = ArmDeploymentParametersLink.DeserializeArmDeploymentParametersLink(property.Value); continue; } if (property.NameEquals("mode"u8)) @@ -189,7 +189,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - debugSetting = DebugSetting.DeserializeDebugSetting(property.Value, options); + debugSetting = DebugSetting.DeserializeDebugSetting(property.Value); continue; } if (property.NameEquals("onErrorDeployment"u8)) @@ -198,7 +198,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - onErrorDeployment = ErrorDeployment.DeserializeErrorDeployment(property.Value, options); + onErrorDeployment = ErrorDeployment.DeserializeErrorDeployment(property.Value); continue; } if (property.NameEquals("expressionEvaluationOptions"u8)) @@ -207,7 +207,7 @@ internal static ArmDeploymentWhatIfProperties DeserializeArmDeploymentWhatIfProp { continue; } - expressionEvaluationOptions = ExpressionEvaluationOptions.DeserializeExpressionEvaluationOptions(property.Value, options); + expressionEvaluationOptions = ExpressionEvaluationOptions.DeserializeExpressionEvaluationOptions(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzureCliScript.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzureCliScript.Serialization.cs index 1bd53a5a9d3de..d4b4b04b1b3ec 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzureCliScript.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzureCliScript.Serialization.cs @@ -235,7 +235,7 @@ internal static AzureCliScript DeserializeAzureCliScript(JsonElement element, Mo { continue; } - identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value, options); + identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value); continue; } if (property.NameEquals("location"u8)) @@ -301,7 +301,7 @@ internal static AzureCliScript DeserializeAzureCliScript(JsonElement element, Mo { continue; } - containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property0.Value, options); + containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property0.Value); continue; } if (property0.NameEquals("storageAccountSettings"u8)) @@ -310,7 +310,7 @@ internal static AzureCliScript DeserializeAzureCliScript(JsonElement element, Mo { continue; } - storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property0.Value, options); + storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property0.Value); continue; } if (property0.NameEquals("cleanupPreference"u8)) @@ -337,7 +337,7 @@ internal static AzureCliScript DeserializeAzureCliScript(JsonElement element, Mo { continue; } - status = ScriptStatus.DeserializeScriptStatus(property0.Value, options); + status = ScriptStatus.DeserializeScriptStatus(property0.Value); continue; } if (property0.NameEquals("outputs"u8)) @@ -398,7 +398,7 @@ internal static AzureCliScript DeserializeAzureCliScript(JsonElement element, Mo List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ScriptEnvironmentVariable.DeserializeScriptEnvironmentVariable(item, options)); + array.Add(ScriptEnvironmentVariable.DeserializeScriptEnvironmentVariable(item)); } environmentVariables = array; continue; @@ -453,21 +453,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -475,14 +475,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -491,17 +491,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -509,12 +509,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -525,56 +525,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.ToString()}'"); + builder.AppendLine($"'{Kind.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -583,98 +583,98 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerSettings), out propertyOverride); if (Optional.IsDefined(ContainerSettings) || hasPropertyOverride) { - builder.Append(" containerSettings:"); + builder.Append(" containerSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContainerSettings, options, 4, false); + AppendChildObject(builder, ContainerSettings, options, 4, false, " containerSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSettings), out propertyOverride); if (Optional.IsDefined(StorageAccountSettings) || hasPropertyOverride) { - builder.Append(" storageAccountSettings:"); + builder.Append(" storageAccountSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StorageAccountSettings, options, 4, false); + AppendChildObject(builder, StorageAccountSettings, options, 4, false, " storageAccountSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CleanupPreference), out propertyOverride); if (Optional.IsDefined(CleanupPreference) || hasPropertyOverride) { - builder.Append(" cleanupPreference:"); + builder.Append(" cleanupPreference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CleanupPreference.Value.ToString()}'"); + builder.AppendLine($"'{CleanupPreference.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Status, options, 4, false); + AppendChildObject(builder, Status, options, 4, false, " status: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Outputs), out propertyOverride); if (Optional.IsDefined(Outputs) || hasPropertyOverride) { - builder.Append(" outputs:"); + builder.Append(" outputs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Outputs.ToString()}'"); + builder.AppendLine($"'{Outputs.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryScriptUri), out propertyOverride); if (Optional.IsDefined(PrimaryScriptUri) || hasPropertyOverride) { - builder.Append(" primaryScriptUri:"); + builder.Append(" primaryScriptUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryScriptUri.AbsoluteUri}'"); + builder.AppendLine($"'{PrimaryScriptUri.AbsoluteUri}'"); } } @@ -683,14 +683,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportingScriptUris.Any() || hasPropertyOverride) { - builder.Append(" supportingScriptUris:"); + builder.Append(" supportingScriptUris: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportingScriptUris) { if (item == null) @@ -708,21 +708,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScriptContent), out propertyOverride); if (Optional.IsDefined(ScriptContent) || hasPropertyOverride) { - builder.Append(" scriptContent:"); + builder.Append(" scriptContent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScriptContent.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScriptContent}'''"); } else { - builder.AppendLine($" '{ScriptContent}'"); + builder.AppendLine($"'{ScriptContent}'"); } } } @@ -730,21 +730,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); if (Optional.IsDefined(Arguments) || hasPropertyOverride) { - builder.Append(" arguments:"); + builder.Append(" arguments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Arguments.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Arguments}'''"); } else { - builder.AppendLine($" '{Arguments}'"); + builder.AppendLine($"'{Arguments}'"); } } } @@ -754,17 +754,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EnvironmentVariables.Any() || hasPropertyOverride) { - builder.Append(" environmentVariables:"); + builder.Append(" environmentVariables: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EnvironmentVariables) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " environmentVariables: "); } builder.AppendLine(" ]"); } @@ -774,21 +774,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForceUpdateTag), out propertyOverride); if (Optional.IsDefined(ForceUpdateTag) || hasPropertyOverride) { - builder.Append(" forceUpdateTag:"); + builder.Append(" forceUpdateTag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ForceUpdateTag.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ForceUpdateTag}'''"); } else { - builder.AppendLine($" '{ForceUpdateTag}'"); + builder.AppendLine($"'{ForceUpdateTag}'"); } } } @@ -796,51 +796,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInterval), out propertyOverride); if (Optional.IsDefined(RetentionInterval) || hasPropertyOverride) { - builder.Append(" retentionInterval:"); + builder.Append(" retentionInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(RetentionInterval, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timeout), out propertyOverride); if (Optional.IsDefined(Timeout) || hasPropertyOverride) { - builder.Append(" timeout:"); + builder.Append(" timeout: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Timeout.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzCliVersion), out propertyOverride); if (Optional.IsDefined(AzCliVersion) || hasPropertyOverride) { - builder.Append(" azCliVersion:"); + builder.Append(" azCliVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzCliVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzCliVersion}'''"); } else { - builder.AppendLine($" '{AzCliVersion}'"); + builder.AppendLine($"'{AzCliVersion}'"); } } } @@ -850,12 +850,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -876,13 +879,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzurePowerShellScript.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzurePowerShellScript.Serialization.cs index 3c5bc378183c0..2648d9284bc12 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzurePowerShellScript.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/AzurePowerShellScript.Serialization.cs @@ -235,7 +235,7 @@ internal static AzurePowerShellScript DeserializeAzurePowerShellScript(JsonEleme { continue; } - identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value, options); + identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value); continue; } if (property.NameEquals("location"u8)) @@ -301,7 +301,7 @@ internal static AzurePowerShellScript DeserializeAzurePowerShellScript(JsonEleme { continue; } - containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property0.Value, options); + containerSettings = ContainerConfiguration.DeserializeContainerConfiguration(property0.Value); continue; } if (property0.NameEquals("storageAccountSettings"u8)) @@ -310,7 +310,7 @@ internal static AzurePowerShellScript DeserializeAzurePowerShellScript(JsonEleme { continue; } - storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property0.Value, options); + storageAccountSettings = ScriptStorageConfiguration.DeserializeScriptStorageConfiguration(property0.Value); continue; } if (property0.NameEquals("cleanupPreference"u8)) @@ -337,7 +337,7 @@ internal static AzurePowerShellScript DeserializeAzurePowerShellScript(JsonEleme { continue; } - status = ScriptStatus.DeserializeScriptStatus(property0.Value, options); + status = ScriptStatus.DeserializeScriptStatus(property0.Value); continue; } if (property0.NameEquals("outputs"u8)) @@ -398,7 +398,7 @@ internal static AzurePowerShellScript DeserializeAzurePowerShellScript(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ScriptEnvironmentVariable.DeserializeScriptEnvironmentVariable(item, options)); + array.Add(ScriptEnvironmentVariable.DeserializeScriptEnvironmentVariable(item)); } environmentVariables = array; continue; @@ -453,21 +453,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -475,14 +475,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -491,17 +491,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -509,12 +509,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -525,56 +525,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.ToString()}'"); + builder.AppendLine($"'{Kind.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -583,98 +583,98 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerSettings), out propertyOverride); if (Optional.IsDefined(ContainerSettings) || hasPropertyOverride) { - builder.Append(" containerSettings:"); + builder.Append(" containerSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContainerSettings, options, 4, false); + AppendChildObject(builder, ContainerSettings, options, 4, false, " containerSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSettings), out propertyOverride); if (Optional.IsDefined(StorageAccountSettings) || hasPropertyOverride) { - builder.Append(" storageAccountSettings:"); + builder.Append(" storageAccountSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StorageAccountSettings, options, 4, false); + AppendChildObject(builder, StorageAccountSettings, options, 4, false, " storageAccountSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CleanupPreference), out propertyOverride); if (Optional.IsDefined(CleanupPreference) || hasPropertyOverride) { - builder.Append(" cleanupPreference:"); + builder.Append(" cleanupPreference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CleanupPreference.Value.ToString()}'"); + builder.AppendLine($"'{CleanupPreference.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Status, options, 4, false); + AppendChildObject(builder, Status, options, 4, false, " status: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Outputs), out propertyOverride); if (Optional.IsDefined(Outputs) || hasPropertyOverride) { - builder.Append(" outputs:"); + builder.Append(" outputs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Outputs.ToString()}'"); + builder.AppendLine($"'{Outputs.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryScriptUri), out propertyOverride); if (Optional.IsDefined(PrimaryScriptUri) || hasPropertyOverride) { - builder.Append(" primaryScriptUri:"); + builder.Append(" primaryScriptUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryScriptUri.AbsoluteUri}'"); + builder.AppendLine($"'{PrimaryScriptUri.AbsoluteUri}'"); } } @@ -683,14 +683,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportingScriptUris.Any() || hasPropertyOverride) { - builder.Append(" supportingScriptUris:"); + builder.Append(" supportingScriptUris: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportingScriptUris) { if (item == null) @@ -708,21 +708,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScriptContent), out propertyOverride); if (Optional.IsDefined(ScriptContent) || hasPropertyOverride) { - builder.Append(" scriptContent:"); + builder.Append(" scriptContent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScriptContent.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScriptContent}'''"); } else { - builder.AppendLine($" '{ScriptContent}'"); + builder.AppendLine($"'{ScriptContent}'"); } } } @@ -730,21 +730,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); if (Optional.IsDefined(Arguments) || hasPropertyOverride) { - builder.Append(" arguments:"); + builder.Append(" arguments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Arguments.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Arguments}'''"); } else { - builder.AppendLine($" '{Arguments}'"); + builder.AppendLine($"'{Arguments}'"); } } } @@ -754,17 +754,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EnvironmentVariables.Any() || hasPropertyOverride) { - builder.Append(" environmentVariables:"); + builder.Append(" environmentVariables: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EnvironmentVariables) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " environmentVariables: "); } builder.AppendLine(" ]"); } @@ -774,21 +774,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForceUpdateTag), out propertyOverride); if (Optional.IsDefined(ForceUpdateTag) || hasPropertyOverride) { - builder.Append(" forceUpdateTag:"); + builder.Append(" forceUpdateTag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ForceUpdateTag.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ForceUpdateTag}'''"); } else { - builder.AppendLine($" '{ForceUpdateTag}'"); + builder.AppendLine($"'{ForceUpdateTag}'"); } } } @@ -796,51 +796,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInterval), out propertyOverride); if (Optional.IsDefined(RetentionInterval) || hasPropertyOverride) { - builder.Append(" retentionInterval:"); + builder.Append(" retentionInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(RetentionInterval, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timeout), out propertyOverride); if (Optional.IsDefined(Timeout) || hasPropertyOverride) { - builder.Append(" timeout:"); + builder.Append(" timeout: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Timeout.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzPowerShellVersion), out propertyOverride); if (Optional.IsDefined(AzPowerShellVersion) || hasPropertyOverride) { - builder.Append(" azPowerShellVersion:"); + builder.Append(" azPowerShellVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzPowerShellVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzPowerShellVersion}'''"); } else { - builder.AppendLine($" '{AzPowerShellVersion}'"); + builder.AppendLine($"'{AzPowerShellVersion}'"); } } } @@ -850,12 +850,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -876,13 +879,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/BasicArmDependency.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/BasicArmDependency.Serialization.cs index ee4147a921fa1..75e9c3a07faed 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/BasicArmDependency.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/BasicArmDependency.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -152,35 +152,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceType.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ContainerConfiguration.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ContainerConfiguration.Serialization.cs index 670a8753a9bf9..598c886ea215e 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ContainerConfiguration.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ContainerConfiguration.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerGroupName), out propertyOverride); if (Optional.IsDefined(ContainerGroupName) || hasPropertyOverride) { - builder.Append(" containerGroupName:"); + builder.Append(" containerGroupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContainerGroupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContainerGroupName}'''"); } else { - builder.AppendLine($" '{ContainerGroupName}'"); + builder.AppendLine($"'{ContainerGroupName}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/DebugSetting.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/DebugSetting.Serialization.cs index 3104314415887..007c0402759b5 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/DebugSetting.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/DebugSetting.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetailLevel), out propertyOverride); if (Optional.IsDefined(DetailLevel) || hasPropertyOverride) { - builder.Append(" detailLevel:"); + builder.Append(" detailLevel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DetailLevel.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DetailLevel}'''"); } else { - builder.AppendLine($" '{DetailLevel}'"); + builder.AppendLine($"'{DetailLevel}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ErrorDeploymentExtended.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ErrorDeploymentExtended.Serialization.cs index 9575eedac8c9a..bc7f989cd0d25 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ErrorDeploymentExtended.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ErrorDeploymentExtended.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentName), out propertyOverride); if (Optional.IsDefined(DeploymentName) || hasPropertyOverride) { - builder.Append(" deploymentName:"); + builder.Append(" deploymentName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeploymentName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeploymentName}'''"); } else { - builder.AppendLine($" '{DeploymentName}'"); + builder.AppendLine($"'{DeploymentName}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/HttpMessage.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/HttpMessage.Serialization.cs index 7842d028b1dee..05e71d81bd312 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/HttpMessage.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/HttpMessage.Serialization.cs @@ -115,14 +115,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Content), out propertyOverride); if (Optional.IsDefined(Content) || hasPropertyOverride) { - builder.Append(" content:"); + builder.Append(" content: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Content.ToString()}'"); + builder.AppendLine($"'{Content.ToString()}'"); } } @@ -130,12 +130,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -156,13 +159,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitApprover.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitApprover.Serialization.cs index 37c197809926a..cc1be89500a24 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitApprover.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitApprover.Serialization.cs @@ -127,21 +127,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -149,21 +149,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -172,12 +172,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -198,13 +201,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitAuthorizationPolicies.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitAuthorizationPolicies.Serialization.cs index 5698df4ff8dee..df6fce92f376d 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitAuthorizationPolicies.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitAuthorizationPolicies.Serialization.cs @@ -109,35 +109,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.ToString()}'"); + builder.AppendLine($"'{PrincipalId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoleDefinitionId), out propertyOverride); if (Optional.IsDefined(RoleDefinitionId) || hasPropertyOverride) { - builder.Append(" roleDefinitionId:"); + builder.Append(" roleDefinitionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RoleDefinitionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RoleDefinitionId}'''"); } else { - builder.AppendLine($" '{RoleDefinitionId}'"); + builder.AppendLine($"'{RoleDefinitionId}'"); } } } @@ -146,12 +146,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -172,13 +175,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitRequestListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitRequestListResult.Serialization.cs index 807afc1650192..22f751389f96c 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitRequestListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitRequestListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JitRequestListResult DeserializeJitRequestListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(JitRequestData.DeserializeJitRequestData(item, options)); + array.Add(JitRequestData.DeserializeJitRequestData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitSchedulingPolicy.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitSchedulingPolicy.Serialization.cs index 08aa9891333b2..c397e139a7ad4 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitSchedulingPolicy.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/JitSchedulingPolicy.Serialization.cs @@ -120,30 +120,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Duration), out propertyOverride); if (Optional.IsDefined(Duration) || hasPropertyOverride) { - builder.Append(" duration:"); + builder.Append(" duration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Duration, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -151,12 +151,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -177,13 +180,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/LinkedTemplateArtifact.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/LinkedTemplateArtifact.Serialization.cs index f9649e6893e9a..ad62ae60c9f23 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/LinkedTemplateArtifact.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/LinkedTemplateArtifact.Serialization.cs @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -138,14 +138,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); if (Optional.IsDefined(Template) || hasPropertyOverride) { - builder.Append(" template:"); + builder.Append(" template: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Template.ToString()}'"); + builder.AppendLine($"'{Template.ToString()}'"); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptEnvironmentVariable.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptEnvironmentVariable.Serialization.cs index 06b76cb5cdc1c..8978685cb137b 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptEnvironmentVariable.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptEnvironmentVariable.Serialization.cs @@ -123,21 +123,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecureValue), out propertyOverride); if (Optional.IsDefined(SecureValue) || hasPropertyOverride) { - builder.Append(" secureValue:"); + builder.Append(" secureValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecureValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecureValue}'''"); } else { - builder.AppendLine($" '{SecureValue}'"); + builder.AppendLine($"'{SecureValue}'"); } } } @@ -190,12 +190,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -216,13 +219,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptLogsList.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptLogsList.Serialization.cs index 82257e771ca45..872da6c7b8150 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptLogsList.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptLogsList.Serialization.cs @@ -92,7 +92,7 @@ internal static ScriptLogsList DeserializeScriptLogsList(JsonElement element, Mo List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ScriptLogData.DeserializeScriptLogData(item, options)); + array.Add(ScriptLogData.DeserializeScriptLogData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStatus.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStatus.Serialization.cs index c81e3b7c71009..d12a17896ee0d 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStatus.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStatus.Serialization.cs @@ -176,21 +176,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerInstanceId), out propertyOverride); if (Optional.IsDefined(ContainerInstanceId) || hasPropertyOverride) { - builder.Append(" containerInstanceId:"); + builder.Append(" containerInstanceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContainerInstanceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContainerInstanceId}'''"); } else { - builder.AppendLine($" '{ContainerInstanceId}'"); + builder.AppendLine($"'{ContainerInstanceId}'"); } } } @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountId), out propertyOverride); if (Optional.IsDefined(StorageAccountId) || hasPropertyOverride) { - builder.Append(" storageAccountId:"); + builder.Append(" storageAccountId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountId}'''"); } else { - builder.AppendLine($" '{StorageAccountId}'"); + builder.AppendLine($"'{StorageAccountId}'"); } } } @@ -220,59 +220,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -280,12 +280,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -306,13 +309,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStorageConfiguration.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStorageConfiguration.Serialization.cs index 19e9cdc991bcc..da19ecc3ab2d1 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStorageConfiguration.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/ScriptStorageConfiguration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountName), out propertyOverride); if (Optional.IsDefined(StorageAccountName) || hasPropertyOverride) { - builder.Append(" storageAccountName:"); + builder.Append(" storageAccountName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountName}'''"); } else { - builder.AppendLine($" '{StorageAccountName}'"); + builder.AppendLine($"'{StorageAccountName}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountKey), out propertyOverride); if (Optional.IsDefined(StorageAccountKey) || hasPropertyOverride) { - builder.Append(" storageAccountKey:"); + builder.Append(" storageAccountKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountKey}'''"); } else { - builder.AppendLine($" '{StorageAccountKey}'"); + builder.AppendLine($"'{StorageAccountKey}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/StatusMessage.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/StatusMessage.Serialization.cs index 76bbdf159c46c..38444b2e1e2ba 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/StatusMessage.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/StatusMessage.Serialization.cs @@ -120,21 +120,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -142,14 +142,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TargetResource.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TargetResource.Serialization.cs index 55666a8ad5e30..21eec4c9b598f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TargetResource.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TargetResource.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceType.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateHashResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateHashResult.Serialization.cs index 5b65db481f0b3..2489a716ad1b7 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateHashResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateHashResult.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinifiedTemplate), out propertyOverride); if (Optional.IsDefined(MinifiedTemplate) || hasPropertyOverride) { - builder.Append(" minifiedTemplate:"); + builder.Append(" minifiedTemplate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MinifiedTemplate.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MinifiedTemplate}'''"); } else { - builder.AppendLine($" '{MinifiedTemplate}'"); + builder.AppendLine($"'{MinifiedTemplate}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateHash), out propertyOverride); if (Optional.IsDefined(TemplateHash) || hasPropertyOverride) { - builder.Append(" templateHash:"); + builder.Append(" templateHash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TemplateHash.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TemplateHash}'''"); } else { - builder.AppendLine($" '{TemplateHash}'"); + builder.AppendLine($"'{TemplateHash}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecPatch.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecPatch.Serialization.cs index 8b9eb03cdf94d..7a9ae24d06ea6 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecPatch.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecPatch.Serialization.cs @@ -169,21 +169,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,17 +193,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -211,12 +211,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -256,12 +256,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -282,13 +285,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionInfo.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionInfo.Serialization.cs index e4b61eb127955..730d134424ad6 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionInfo.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionInfo.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -156,30 +156,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeCreated), out propertyOverride); if (Optional.IsDefined(TimeCreated) || hasPropertyOverride) { - builder.Append(" timeCreated:"); + builder.Append(" timeCreated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeCreated.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeModified), out propertyOverride); if (Optional.IsDefined(TimeModified) || hasPropertyOverride) { - builder.Append(" timeModified:"); + builder.Append(" timeModified: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeModified.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -187,12 +187,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -213,13 +216,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionPatch.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionPatch.Serialization.cs index ec3975e2bfce5..be58c46963999 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionPatch.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionPatch.Serialization.cs @@ -169,21 +169,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,17 +193,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -211,12 +211,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -256,12 +256,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -282,13 +285,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionsListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionsListResult.Serialization.cs index 3f3e141df9c5d..0bf090a5de2e8 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionsListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecVersionsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static TemplateSpecVersionsListResult DeserializeTemplateSpecVersionsLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TemplateSpecVersionData.DeserializeTemplateSpecVersionData(item, options)); + array.Add(TemplateSpecVersionData.DeserializeTemplateSpecVersionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecsListResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecsListResult.Serialization.cs index f95712cf8f3ee..897c167909480 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecsListResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/TemplateSpecsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static TemplateSpecsListResult DeserializeTemplateSpecsListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TemplateSpecData.DeserializeTemplateSpecData(item, options)); + array.Add(TemplateSpecData.DeserializeTemplateSpecData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/UnknownArmDeploymentScript.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/UnknownArmDeploymentScript.Serialization.cs index a8b5c4407083d..f9801e9ba6870 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/UnknownArmDeploymentScript.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/UnknownArmDeploymentScript.Serialization.cs @@ -98,7 +98,7 @@ ArmDeploymentScriptData IJsonModel.Create(ref Utf8JsonR } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeArmDeploymentScriptData(document.RootElement, options); + return DeserializeUnknownArmDeploymentScript(document.RootElement, options); } internal static UnknownArmDeploymentScript DeserializeUnknownArmDeploymentScript(JsonElement element, ModelReaderWriterOptions options = null) @@ -127,7 +127,7 @@ internal static UnknownArmDeploymentScript DeserializeUnknownArmDeploymentScript { continue; } - identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value, options); + identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value); continue; } if (property.NameEquals("location"u8)) @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -223,14 +223,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -239,17 +239,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -257,12 +257,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -273,56 +273,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.ToString()}'"); + builder.AppendLine($"'{Kind.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -330,12 +330,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -356,13 +359,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) @@ -389,7 +396,7 @@ ArmDeploymentScriptData IPersistableModel.Create(Binary case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeArmDeploymentScriptData(document.RootElement, options); + return DeserializeUnknownArmDeploymentScript(document.RootElement, options); } case "bicep": throw new InvalidOperationException("Bicep deserialization is not supported for this type."); diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfChange.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfChange.Serialization.cs index ea9d342b4db43..11046d91da50f 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfChange.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfChange.Serialization.cs @@ -162,7 +162,7 @@ internal static WhatIfChange DeserializeWhatIfChange(JsonElement element, ModelR List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(WhatIfPropertyChange.DeserializeWhatIfPropertyChange(item, options)); + array.Add(WhatIfPropertyChange.DeserializeWhatIfPropertyChange(item)); } delta = array; continue; @@ -190,21 +190,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); if (Optional.IsDefined(ResourceId) || hasPropertyOverride) { - builder.Append(" resourceId:"); + builder.Append(" resourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceId}'''"); } else { - builder.AppendLine($" '{ResourceId}'"); + builder.AppendLine($"'{ResourceId}'"); } } } @@ -212,35 +212,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeType), out propertyOverride); if (Optional.IsDefined(ChangeType) || hasPropertyOverride) { - builder.Append(" changeType:"); + builder.Append(" changeType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ChangeType.ToSerialString()}'"); + builder.AppendLine($"'{ChangeType.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UnsupportedReason), out propertyOverride); if (Optional.IsDefined(UnsupportedReason) || hasPropertyOverride) { - builder.Append(" unsupportedReason:"); + builder.Append(" unsupportedReason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UnsupportedReason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UnsupportedReason}'''"); } else { - builder.AppendLine($" '{UnsupportedReason}'"); + builder.AppendLine($"'{UnsupportedReason}'"); } } } @@ -248,28 +248,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Before), out propertyOverride); if (Optional.IsDefined(Before) || hasPropertyOverride) { - builder.Append(" before:"); + builder.Append(" before: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Before.ToString()}'"); + builder.AppendLine($"'{Before.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(After), out propertyOverride); if (Optional.IsDefined(After) || hasPropertyOverride) { - builder.Append(" after:"); + builder.Append(" after: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{After.ToString()}'"); + builder.AppendLine($"'{After.ToString()}'"); } } @@ -278,17 +278,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Delta.Any() || hasPropertyOverride) { - builder.Append(" delta:"); + builder.Append(" delta: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Delta) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " delta: "); } builder.AppendLine(" ]"); } @@ -299,12 +299,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -325,13 +328,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfOperationResult.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfOperationResult.Serialization.cs index ca1f91b8752bc..bd8c0eab24319 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfOperationResult.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfOperationResult.Serialization.cs @@ -130,7 +130,7 @@ internal static WhatIfOperationResult DeserializeWhatIfOperationResult(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(WhatIfChange.DeserializeWhatIfChange(item, options)); + array.Add(WhatIfChange.DeserializeWhatIfChange(item)); } changes = array; continue; @@ -161,21 +161,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -183,14 +183,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -201,17 +201,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Changes.Any() || hasPropertyOverride) { - builder.Append(" changes:"); + builder.Append(" changes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Changes) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " changes: "); } builder.AppendLine(" ]"); } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfPropertyChange.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfPropertyChange.Serialization.cs index b96164208e8d0..38d0cdfcb42d8 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfPropertyChange.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/Models/WhatIfPropertyChange.Serialization.cs @@ -151,7 +151,7 @@ internal static WhatIfPropertyChange DeserializeWhatIfPropertyChange(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeWhatIfPropertyChange(item, options)); + array.Add(DeserializeWhatIfPropertyChange(item)); } children = array; continue; @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -201,42 +201,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PropertyChangeType), out propertyOverride); if (Optional.IsDefined(PropertyChangeType) || hasPropertyOverride) { - builder.Append(" propertyChangeType:"); + builder.Append(" propertyChangeType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PropertyChangeType.ToSerialString()}'"); + builder.AppendLine($"'{PropertyChangeType.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Before), out propertyOverride); if (Optional.IsDefined(Before) || hasPropertyOverride) { - builder.Append(" before:"); + builder.Append(" before: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Before.ToString()}'"); + builder.AppendLine($"'{Before.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(After), out propertyOverride); if (Optional.IsDefined(After) || hasPropertyOverride) { - builder.Append(" after:"); + builder.Append(" after: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{After.ToString()}'"); + builder.AppendLine($"'{After.ToString()}'"); } } @@ -245,17 +245,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Children.Any() || hasPropertyOverride) { - builder.Append(" children:"); + builder.Append(" children: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Children) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " children: "); } builder.AppendLine(" ]"); } @@ -266,12 +266,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -292,13 +295,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ScriptLogData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ScriptLogData.Serialization.cs index edad2fded54ca..254f3260b9e0b 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ScriptLogData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/ScriptLogData.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Log), out propertyOverride); if (Optional.IsDefined(Log) || hasPropertyOverride) { - builder.Append(" log:"); + builder.Append(" log: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Log.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Log}'''"); } else { - builder.AppendLine($" '{Log}'"); + builder.AppendLine($"'{Log}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecData.Serialization.cs index 9c7aa537b4764..1ee2992310d77 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecData.Serialization.cs @@ -232,7 +232,7 @@ internal static TemplateSpecData DeserializeTemplateSpecData(JsonElement element Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, TemplateSpecVersionInfo.DeserializeTemplateSpecVersionInfo(property1.Value, options)); + dictionary.Add(property1.Name, TemplateSpecVersionInfo.DeserializeTemplateSpecVersionInfo(property1.Value)); } versions = dictionary; continue; @@ -263,21 +263,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -285,14 +285,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -301,17 +301,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -319,12 +319,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -335,28 +335,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -365,21 +365,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -387,21 +387,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -409,14 +409,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Metadata.ToString()}'"); + builder.AppendLine($"'{Metadata.ToString()}'"); } } @@ -425,18 +425,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Versions.Any() || hasPropertyOverride) { - builder.Append(" versions:"); + builder.Append(" versions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Versions) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " versions: "); } builder.AppendLine(" }"); } @@ -448,12 +448,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -474,13 +477,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecVersionData.Serialization.cs b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecVersionData.Serialization.cs index 193ace86435cd..07626a2381040 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecVersionData.Serialization.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/src/Generated/TemplateSpecVersionData.Serialization.cs @@ -237,7 +237,7 @@ internal static TemplateSpecVersionData DeserializeTemplateSpecVersionData(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(LinkedTemplateArtifact.DeserializeLinkedTemplateArtifact(item, options)); + array.Add(LinkedTemplateArtifact.DeserializeLinkedTemplateArtifact(item)); } linkedTemplates = array; continue; @@ -295,21 +295,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -317,14 +317,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -333,17 +333,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -351,12 +351,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -367,28 +367,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -397,21 +397,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -421,17 +421,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LinkedTemplates.Any() || hasPropertyOverride) { - builder.Append(" linkedTemplates:"); + builder.Append(" linkedTemplates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LinkedTemplates) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " linkedTemplates: "); } builder.AppendLine(" ]"); } @@ -441,42 +441,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Metadata.ToString()}'"); + builder.AppendLine($"'{Metadata.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MainTemplate), out propertyOverride); if (Optional.IsDefined(MainTemplate) || hasPropertyOverride) { - builder.Append(" mainTemplate:"); + builder.Append(" mainTemplate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MainTemplate.ToString()}'"); + builder.AppendLine($"'{MainTemplate.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UiFormDefinition), out propertyOverride); if (Optional.IsDefined(UiFormDefinition) || hasPropertyOverride) { - builder.Append(" uiFormDefinition:"); + builder.Append(" uiFormDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UiFormDefinition.ToString()}'"); + builder.AppendLine($"'{UiFormDefinition.ToString()}'"); } } @@ -485,12 +485,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -511,13 +514,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/BackupShortTermRetentionPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/BackupShortTermRetentionPolicyData.Serialization.cs index b229bc5ba853d..f20055de8e782 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/BackupShortTermRetentionPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/BackupShortTermRetentionPolicyData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,24 +240,24 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DiffBackupIntervalInHours), out propertyOverride); if (Optional.IsDefined(DiffBackupIntervalInHours) || hasPropertyOverride) { - builder.Append(" diffBackupIntervalInHours:"); + builder.Append(" diffBackupIntervalInHours: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { @@ -270,12 +270,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -296,13 +299,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataMaskingPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataMaskingPolicyData.Serialization.cs index 30415dc309622..77d9145fc11fd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataMaskingPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataMaskingPolicyData.Serialization.cs @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -254,35 +254,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -290,28 +290,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -320,35 +320,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataMaskingState), out propertyOverride); if (Optional.IsDefined(DataMaskingState) || hasPropertyOverride) { - builder.Append(" dataMaskingState:"); + builder.Append(" dataMaskingState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DataMaskingState.Value.ToSerialString()}'"); + builder.AppendLine($"'{DataMaskingState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExemptPrincipals), out propertyOverride); if (Optional.IsDefined(ExemptPrincipals) || hasPropertyOverride) { - builder.Append(" exemptPrincipals:"); + builder.Append(" exemptPrincipals: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ExemptPrincipals.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ExemptPrincipals}'''"); } else { - builder.AppendLine($" '{ExemptPrincipals}'"); + builder.AppendLine($"'{ExemptPrincipals}'"); } } } @@ -356,21 +356,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationPrincipals), out propertyOverride); if (Optional.IsDefined(ApplicationPrincipals) || hasPropertyOverride) { - builder.Append(" applicationPrincipals:"); + builder.Append(" applicationPrincipals: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApplicationPrincipals.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApplicationPrincipals}'''"); } else { - builder.AppendLine($" '{ApplicationPrincipals}'"); + builder.AppendLine($"'{ApplicationPrincipals}'"); } } } @@ -378,21 +378,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaskingLevel), out propertyOverride); if (Optional.IsDefined(MaskingLevel) || hasPropertyOverride) { - builder.Append(" maskingLevel:"); + builder.Append(" maskingLevel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MaskingLevel.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MaskingLevel}'''"); } else { - builder.AppendLine($" '{MaskingLevel}'"); + builder.AppendLine($"'{MaskingLevel}'"); } } } @@ -402,12 +402,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -428,13 +431,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataWarehouseUserActivityData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataWarehouseUserActivityData.Serialization.cs index 08fd71fab2575..87af5e0abe88c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataWarehouseUserActivityData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DataWarehouseUserActivityData.Serialization.cs @@ -172,21 +172,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -194,28 +194,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -224,14 +224,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActiveQueriesCount), out propertyOverride); if (Optional.IsDefined(ActiveQueriesCount) || hasPropertyOverride) { - builder.Append(" activeQueriesCount:"); + builder.Append(" activeQueriesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ActiveQueriesCount.Value}"); + builder.AppendLine($"{ActiveQueriesCount.Value}"); } } @@ -240,12 +240,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -266,13 +269,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.Serialization.cs index 06fcd41acb993..ec22d50f28d10 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseColumnData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseColumnData.Serialization.cs index 41e15fba27cff..9cc82ed188674 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseColumnData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseColumnData.Serialization.cs @@ -218,21 +218,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -240,28 +240,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -270,58 +270,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnType), out propertyOverride); if (Optional.IsDefined(ColumnType) || hasPropertyOverride) { - builder.Append(" columnType:"); + builder.Append(" columnType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ColumnType.Value.ToString()}'"); + builder.AppendLine($"'{ColumnType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemporalType), out propertyOverride); if (Optional.IsDefined(TemporalType) || hasPropertyOverride) { - builder.Append(" temporalType:"); + builder.Append(" temporalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TemporalType.Value.ToString()}'"); + builder.AppendLine($"'{TemporalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMemoryOptimized), out propertyOverride); if (Optional.IsDefined(IsMemoryOptimized) || hasPropertyOverride) { - builder.Append(" memoryOptimized:"); + builder.Append(" memoryOptimized: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsMemoryOptimized.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsComputed), out propertyOverride); if (Optional.IsDefined(IsComputed) || hasPropertyOverride) { - builder.Append(" isComputed:"); + builder.Append(" isComputed: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsComputed.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -330,12 +330,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -356,13 +359,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseSchemaData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseSchemaData.Serialization.cs index 3e1cbe0d57b2b..e79a36bf96147 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseSchemaData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseSchemaData.Serialization.cs @@ -142,21 +142,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -164,28 +164,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseTableData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseTableData.Serialization.cs index 241efc8ef413e..654b13448b486 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseTableData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseTableData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemporalType), out propertyOverride); if (Optional.IsDefined(TemporalType) || hasPropertyOverride) { - builder.Append(" temporalType:"); + builder.Append(" temporalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TemporalType.Value.ToString()}'"); + builder.AppendLine($"'{TemporalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMemoryOptimized), out propertyOverride); if (Optional.IsDefined(IsMemoryOptimized) || hasPropertyOverride) { - builder.Append(" memoryOptimized:"); + builder.Append(" memoryOptimized: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsMemoryOptimized.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentData.Serialization.cs index 0d97ce409543b..4f60dc6116540 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentData.Serialization.cs @@ -177,7 +177,7 @@ internal static DatabaseVulnerabilityAssessmentData DeserializeDatabaseVulnerabi { continue; } - recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value, options); + recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value); continue; } } @@ -206,21 +206,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -228,28 +228,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerPath), out propertyOverride); if (Optional.IsDefined(StorageContainerPath) || hasPropertyOverride) { - builder.Append(" storageContainerPath:"); + builder.Append(" storageContainerPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerPath}'''"); } else { - builder.AppendLine($" '{StorageContainerPath}'"); + builder.AppendLine($"'{StorageContainerPath}'"); } } } @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerSasKey), out propertyOverride); if (Optional.IsDefined(StorageContainerSasKey) || hasPropertyOverride) { - builder.Append(" storageContainerSasKey:"); + builder.Append(" storageContainerSasKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerSasKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerSasKey}'''"); } else { - builder.AppendLine($" '{StorageContainerSasKey}'"); + builder.AppendLine($"'{StorageContainerSasKey}'"); } } } @@ -302,21 +302,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -324,14 +324,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecurringScans), out propertyOverride); if (Optional.IsDefined(RecurringScans) || hasPropertyOverride) { - builder.Append(" recurringScans:"); + builder.Append(" recurringScans: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RecurringScans, options, 4, false); + AppendChildObject(builder, RecurringScans, options, 4, false, " recurringScans: "); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentRuleBaselineData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentRuleBaselineData.Serialization.cs index 28809c406c43e..2429e18dc7aa2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentRuleBaselineData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseVulnerabilityAssessmentRuleBaselineData.Serialization.cs @@ -153,7 +153,7 @@ internal static DatabaseVulnerabilityAssessmentRuleBaselineData DeserializeDatab List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(DatabaseVulnerabilityAssessmentRuleBaselineItem.DeserializeDatabaseVulnerabilityAssessmentRuleBaselineItem(item, options)); + array.Add(DatabaseVulnerabilityAssessmentRuleBaselineItem.DeserializeDatabaseVulnerabilityAssessmentRuleBaselineItem(item)); } baselineResults = array; continue; @@ -184,21 +184,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -206,28 +206,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -238,17 +238,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BaselineResults.Any() || hasPropertyOverride) { - builder.Append(" baselineResults:"); + builder.Append(" baselineResults: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BaselineResults) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " baselineResults: "); } builder.AppendLine(" ]"); } @@ -260,12 +260,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -286,13 +289,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DeletedServerData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DeletedServerData.Serialization.cs index 5530ceec447b2..89a7bd6ade230 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DeletedServerData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DeletedServerData.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,28 +231,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -261,21 +261,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -283,50 +283,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionTime:"); + builder.Append(" deletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OriginalId), out propertyOverride); if (Optional.IsDefined(OriginalId) || hasPropertyOverride) { - builder.Append(" originalId:"); + builder.Append(" originalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OriginalId.ToString()}'"); + builder.AppendLine($"'{OriginalId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainName), out propertyOverride); if (Optional.IsDefined(FullyQualifiedDomainName) || hasPropertyOverride) { - builder.Append(" fullyQualifiedDomainName:"); + builder.Append(" fullyQualifiedDomainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FullyQualifiedDomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FullyQualifiedDomainName}'''"); } else { - builder.AppendLine($" '{FullyQualifiedDomainName}'"); + builder.AppendLine($"'{FullyQualifiedDomainName}'"); } } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.Serialization.cs index 04e6b72d5c648..70cf42e8830f9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.Serialization.cs @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -306,28 +306,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -336,21 +336,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetDatabase), out propertyOverride); if (Optional.IsDefined(TargetDatabase) || hasPropertyOverride) { - builder.Append(" targetDatabase:"); + builder.Append(" targetDatabase: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TargetDatabase.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TargetDatabase}'''"); } else { - builder.AppendLine($" '{TargetDatabase}'"); + builder.AppendLine($"'{TargetDatabase}'"); } } } @@ -358,21 +358,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceEndpoint), out propertyOverride); if (Optional.IsDefined(SourceEndpoint) || hasPropertyOverride) { - builder.Append(" sourceEndpoint:"); + builder.Append(" sourceEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceEndpoint}'''"); } else { - builder.AppendLine($" '{SourceEndpoint}'"); + builder.AppendLine($"'{SourceEndpoint}'"); } } } @@ -380,21 +380,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryAvailabilityGroupName), out propertyOverride); if (Optional.IsDefined(PrimaryAvailabilityGroupName) || hasPropertyOverride) { - builder.Append(" primaryAvailabilityGroupName:"); + builder.Append(" primaryAvailabilityGroupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrimaryAvailabilityGroupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrimaryAvailabilityGroupName}'''"); } else { - builder.AppendLine($" '{PrimaryAvailabilityGroupName}'"); + builder.AppendLine($"'{PrimaryAvailabilityGroupName}'"); } } } @@ -402,21 +402,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondaryAvailabilityGroupName), out propertyOverride); if (Optional.IsDefined(SecondaryAvailabilityGroupName) || hasPropertyOverride) { - builder.Append(" secondaryAvailabilityGroupName:"); + builder.Append(" secondaryAvailabilityGroupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecondaryAvailabilityGroupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecondaryAvailabilityGroupName}'''"); } else { - builder.AppendLine($" '{SecondaryAvailabilityGroupName}'"); + builder.AppendLine($"'{SecondaryAvailabilityGroupName}'"); } } } @@ -424,77 +424,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationMode), out propertyOverride); if (Optional.IsDefined(ReplicationMode) || hasPropertyOverride) { - builder.Append(" replicationMode:"); + builder.Append(" replicationMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationMode.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DistributedAvailabilityGroupId), out propertyOverride); if (Optional.IsDefined(DistributedAvailabilityGroupId) || hasPropertyOverride) { - builder.Append(" distributedAvailabilityGroupId:"); + builder.Append(" distributedAvailabilityGroupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DistributedAvailabilityGroupId.Value.ToString()}'"); + builder.AppendLine($"'{DistributedAvailabilityGroupId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceReplicaId), out propertyOverride); if (Optional.IsDefined(SourceReplicaId) || hasPropertyOverride) { - builder.Append(" sourceReplicaId:"); + builder.Append(" sourceReplicaId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceReplicaId.Value.ToString()}'"); + builder.AppendLine($"'{SourceReplicaId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetReplicaId), out propertyOverride); if (Optional.IsDefined(TargetReplicaId) || hasPropertyOverride) { - builder.Append(" targetReplicaId:"); + builder.Append(" targetReplicaId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetReplicaId.Value.ToString()}'"); + builder.AppendLine($"'{TargetReplicaId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinkState), out propertyOverride); if (Optional.IsDefined(LinkState) || hasPropertyOverride) { - builder.Append(" linkState:"); + builder.Append(" linkState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LinkState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LinkState}'''"); } else { - builder.AppendLine($" '{LinkState}'"); + builder.AppendLine($"'{LinkState}'"); } } } @@ -502,21 +502,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastHardenedLsn), out propertyOverride); if (Optional.IsDefined(LastHardenedLsn) || hasPropertyOverride) { - builder.Append(" lastHardenedLsn:"); + builder.Append(" lastHardenedLsn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastHardenedLsn.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastHardenedLsn}'''"); } else { - builder.AppendLine($" '{LastHardenedLsn}'"); + builder.AppendLine($"'{LastHardenedLsn}'"); } } } @@ -526,12 +526,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -552,13 +555,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ElasticPoolData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ElasticPoolData.Serialization.cs index 7e03ab0b86ab0..831f9e9d770b7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ElasticPoolData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ElasticPoolData.Serialization.cs @@ -199,7 +199,7 @@ internal static ElasticPoolData DeserializeElasticPoolData(JsonElement element, { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("kind"u8)) @@ -301,7 +301,7 @@ internal static ElasticPoolData DeserializeElasticPoolData(JsonElement element, { continue; } - perDatabaseSettings = ElasticPoolPerDatabaseSettings.DeserializeElasticPoolPerDatabaseSettings(property0.Value, options); + perDatabaseSettings = ElasticPoolPerDatabaseSettings.DeserializeElasticPoolPerDatabaseSettings(property0.Value); continue; } if (property0.NameEquals("zoneRedundant"u8)) @@ -384,21 +384,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -406,14 +406,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -422,17 +422,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -440,12 +440,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -456,35 +456,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -492,28 +492,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -522,156 +522,156 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxSizeBytes), out propertyOverride); if (Optional.IsDefined(MaxSizeBytes) || hasPropertyOverride) { - builder.Append(" maxSizeBytes:"); + builder.Append(" maxSizeBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxSizeBytes.Value.ToString()}'"); + builder.AppendLine($"'{MaxSizeBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCapacity), out propertyOverride); if (Optional.IsDefined(MinCapacity) || hasPropertyOverride) { - builder.Append(" minCapacity:"); + builder.Append(" minCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinCapacity.Value.ToString()}'"); + builder.AppendLine($"'{MinCapacity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PerDatabaseSettings), out propertyOverride); if (Optional.IsDefined(PerDatabaseSettings) || hasPropertyOverride) { - builder.Append(" perDatabaseSettings:"); + builder.Append(" perDatabaseSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PerDatabaseSettings, options, 4, false); + AppendChildObject(builder, PerDatabaseSettings, options, 4, false, " perDatabaseSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LicenseType), out propertyOverride); if (Optional.IsDefined(LicenseType) || hasPropertyOverride) { - builder.Append(" licenseType:"); + builder.Append(" licenseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LicenseType.Value.ToString()}'"); + builder.AppendLine($"'{LicenseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaintenanceConfigurationId), out propertyOverride); if (Optional.IsDefined(MaintenanceConfigurationId) || hasPropertyOverride) { - builder.Append(" maintenanceConfigurationId:"); + builder.Append(" maintenanceConfigurationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaintenanceConfigurationId.ToString()}'"); + builder.AppendLine($"'{MaintenanceConfigurationId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HighAvailabilityReplicaCount), out propertyOverride); if (Optional.IsDefined(HighAvailabilityReplicaCount) || hasPropertyOverride) { - builder.Append(" highAvailabilityReplicaCount:"); + builder.Append(" highAvailabilityReplicaCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {HighAvailabilityReplicaCount.Value}"); + builder.AppendLine($"{HighAvailabilityReplicaCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreferredEnclaveType), out propertyOverride); if (Optional.IsDefined(PreferredEnclaveType) || hasPropertyOverride) { - builder.Append(" preferredEnclaveType:"); + builder.Append(" preferredEnclaveType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PreferredEnclaveType.Value.ToString()}'"); + builder.AppendLine($"'{PreferredEnclaveType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailabilityZone), out propertyOverride); if (Optional.IsDefined(AvailabilityZone) || hasPropertyOverride) { - builder.Append(" availabilityZone:"); + builder.Append(" availabilityZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AvailabilityZone.Value.ToString()}'"); + builder.AppendLine($"'{AvailabilityZone.Value.ToString()}'"); } } @@ -680,12 +680,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -706,13 +709,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EncryptionProtectorData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EncryptionProtectorData.Serialization.cs index b4246c7a2294c..f789ff43dc7b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EncryptionProtectorData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EncryptionProtectorData.Serialization.cs @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -284,35 +284,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -320,28 +320,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subregion), out propertyOverride); if (Optional.IsDefined(Subregion) || hasPropertyOverride) { - builder.Append(" subregion:"); + builder.Append(" subregion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subregion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subregion}'''"); } else { - builder.AppendLine($" '{Subregion}'"); + builder.AppendLine($"'{Subregion}'"); } } } @@ -372,21 +372,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyName), out propertyOverride); if (Optional.IsDefined(ServerKeyName) || hasPropertyOverride) { - builder.Append(" serverKeyName:"); + builder.Append(" serverKeyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerKeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerKeyName}'''"); } else { - builder.AppendLine($" '{ServerKeyName}'"); + builder.AppendLine($"'{ServerKeyName}'"); } } } @@ -394,49 +394,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyType), out propertyOverride); if (Optional.IsDefined(ServerKeyType) || hasPropertyOverride) { - builder.Append(" serverKeyType:"); + builder.Append(" serverKeyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerKeyType.Value.ToString()}'"); + builder.AppendLine($"'{ServerKeyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -444,15 +444,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRotationEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoRotationEnabled) || hasPropertyOverride) { - builder.Append(" autoRotationEnabled:"); + builder.Append(" autoRotationEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRotationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -461,12 +461,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -487,13 +490,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EndpointCertificateData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EndpointCertificateData.Serialization.cs index a3f1fc80b3fc2..c20f0b8e4052b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EndpointCertificateData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/EndpointCertificateData.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicBlob), out propertyOverride); if (Optional.IsDefined(PublicBlob) || hasPropertyOverride) { - builder.Append(" publicBlob:"); + builder.Append(" publicBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicBlob.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicBlob}'''"); } else { - builder.AppendLine($" '{PublicBlob}'"); + builder.AppendLine($"'{PublicBlob}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedDatabaseBlobAuditingPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedDatabaseBlobAuditingPolicyData.Serialization.cs index c124fb5d8ee81..5c59c4fda57b8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedDatabaseBlobAuditingPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedDatabaseBlobAuditingPolicyData.Serialization.cs @@ -322,21 +322,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -344,28 +344,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -374,21 +374,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PredicateExpression), out propertyOverride); if (Optional.IsDefined(PredicateExpression) || hasPropertyOverride) { - builder.Append(" predicateExpression:"); + builder.Append(" predicateExpression: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PredicateExpression.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PredicateExpression}'''"); } else { - builder.AppendLine($" '{PredicateExpression}'"); + builder.AppendLine($"'{PredicateExpression}'"); } } } @@ -396,14 +396,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } @@ -412,14 +412,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AuditActionsAndGroups.Any() || hasPropertyOverride) { - builder.Append(" auditActionsAndGroups:"); + builder.Append(" auditActionsAndGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AuditActionsAndGroups) { if (item == null) @@ -445,94 +445,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageSecondaryKeyInUse), out propertyOverride); if (Optional.IsDefined(IsStorageSecondaryKeyInUse) || hasPropertyOverride) { - builder.Append(" isStorageSecondaryKeyInUse:"); + builder.Append(" isStorageSecondaryKeyInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageSecondaryKeyInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureMonitorTargetEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureMonitorTargetEnabled) || hasPropertyOverride) { - builder.Append(" isAzureMonitorTargetEnabled:"); + builder.Append(" isAzureMonitorTargetEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureMonitorTargetEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueDelayMs), out propertyOverride); if (Optional.IsDefined(QueueDelayMs) || hasPropertyOverride) { - builder.Append(" queueDelayMs:"); + builder.Append(" queueDelayMs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {QueueDelayMs.Value}"); + builder.AppendLine($"{QueueDelayMs.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManagedIdentityInUse), out propertyOverride); if (Optional.IsDefined(IsManagedIdentityInUse) || hasPropertyOverride) { - builder.Append(" isManagedIdentityInUse:"); + builder.Append(" isManagedIdentityInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManagedIdentityInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -540,21 +540,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -562,14 +562,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSubscriptionId), out propertyOverride); if (Optional.IsDefined(StorageAccountSubscriptionId) || hasPropertyOverride) { - builder.Append(" storageAccountSubscriptionId:"); + builder.Append(" storageAccountSubscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountSubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountSubscriptionId.Value.ToString()}'"); } } @@ -578,12 +578,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -604,13 +607,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedServerBlobAuditingPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedServerBlobAuditingPolicyData.Serialization.cs index 894413f152e1e..b525a6a6acce9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedServerBlobAuditingPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ExtendedServerBlobAuditingPolicyData.Serialization.cs @@ -337,21 +337,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -359,28 +359,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -389,36 +389,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDevopsAuditEnabled), out propertyOverride); if (Optional.IsDefined(IsDevopsAuditEnabled) || hasPropertyOverride) { - builder.Append(" isDevopsAuditEnabled:"); + builder.Append(" isDevopsAuditEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDevopsAuditEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PredicateExpression), out propertyOverride); if (Optional.IsDefined(PredicateExpression) || hasPropertyOverride) { - builder.Append(" predicateExpression:"); + builder.Append(" predicateExpression: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PredicateExpression.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PredicateExpression}'''"); } else { - builder.AppendLine($" '{PredicateExpression}'"); + builder.AppendLine($"'{PredicateExpression}'"); } } } @@ -426,14 +426,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } @@ -442,14 +442,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AuditActionsAndGroups.Any() || hasPropertyOverride) { - builder.Append(" auditActionsAndGroups:"); + builder.Append(" auditActionsAndGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AuditActionsAndGroups) { if (item == null) @@ -475,94 +475,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageSecondaryKeyInUse), out propertyOverride); if (Optional.IsDefined(IsStorageSecondaryKeyInUse) || hasPropertyOverride) { - builder.Append(" isStorageSecondaryKeyInUse:"); + builder.Append(" isStorageSecondaryKeyInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageSecondaryKeyInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureMonitorTargetEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureMonitorTargetEnabled) || hasPropertyOverride) { - builder.Append(" isAzureMonitorTargetEnabled:"); + builder.Append(" isAzureMonitorTargetEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureMonitorTargetEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueDelayMs), out propertyOverride); if (Optional.IsDefined(QueueDelayMs) || hasPropertyOverride) { - builder.Append(" queueDelayMs:"); + builder.Append(" queueDelayMs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {QueueDelayMs.Value}"); + builder.AppendLine($"{QueueDelayMs.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManagedIdentityInUse), out propertyOverride); if (Optional.IsDefined(IsManagedIdentityInUse) || hasPropertyOverride) { - builder.Append(" isManagedIdentityInUse:"); + builder.Append(" isManagedIdentityInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManagedIdentityInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -570,21 +570,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -592,14 +592,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSubscriptionId), out propertyOverride); if (Optional.IsDefined(StorageAccountSubscriptionId) || hasPropertyOverride) { - builder.Append(" storageAccountSubscriptionId:"); + builder.Append(" storageAccountSubscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountSubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountSubscriptionId.Value.ToString()}'"); } } @@ -608,12 +608,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -634,13 +637,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/FailoverGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/FailoverGroupData.Serialization.cs index 1e07a28d8d48e..f0bfbea27633e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/FailoverGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/FailoverGroupData.Serialization.cs @@ -231,7 +231,7 @@ internal static FailoverGroupData DeserializeFailoverGroupData(JsonElement eleme { continue; } - readWriteEndpoint = FailoverGroupReadWriteEndpoint.DeserializeFailoverGroupReadWriteEndpoint(property0.Value, options); + readWriteEndpoint = FailoverGroupReadWriteEndpoint.DeserializeFailoverGroupReadWriteEndpoint(property0.Value); continue; } if (property0.NameEquals("readOnlyEndpoint"u8)) @@ -240,7 +240,7 @@ internal static FailoverGroupData DeserializeFailoverGroupData(JsonElement eleme { continue; } - readOnlyEndpoint = FailoverGroupReadOnlyEndpoint.DeserializeFailoverGroupReadOnlyEndpoint(property0.Value, options); + readOnlyEndpoint = FailoverGroupReadOnlyEndpoint.DeserializeFailoverGroupReadOnlyEndpoint(property0.Value); continue; } if (property0.NameEquals("replicationRole"u8)) @@ -266,7 +266,7 @@ internal static FailoverGroupData DeserializeFailoverGroupData(JsonElement eleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PartnerServerInfo.DeserializePartnerServerInfo(item, options)); + array.Add(PartnerServerInfo.DeserializePartnerServerInfo(item)); } partnerServers = array; continue; @@ -318,21 +318,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -340,14 +340,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -356,17 +356,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -374,12 +374,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -390,28 +390,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -420,63 +420,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadWriteEndpoint), out propertyOverride); if (Optional.IsDefined(ReadWriteEndpoint) || hasPropertyOverride) { - builder.Append(" readWriteEndpoint:"); + builder.Append(" readWriteEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ReadWriteEndpoint, options, 4, false); + AppendChildObject(builder, ReadWriteEndpoint, options, 4, false, " readWriteEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadOnlyEndpoint), out propertyOverride); if (Optional.IsDefined(ReadOnlyEndpoint) || hasPropertyOverride) { - builder.Append(" readOnlyEndpoint:"); + builder.Append(" readOnlyEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ReadOnlyEndpoint, options, 4, false); + AppendChildObject(builder, ReadOnlyEndpoint, options, 4, false, " readOnlyEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) { - builder.Append(" replicationRole:"); + builder.Append(" replicationRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationRole.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationRole.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationState), out propertyOverride); if (Optional.IsDefined(ReplicationState) || hasPropertyOverride) { - builder.Append(" replicationState:"); + builder.Append(" replicationState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ReplicationState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ReplicationState}'''"); } else { - builder.AppendLine($" '{ReplicationState}'"); + builder.AppendLine($"'{ReplicationState}'"); } } } @@ -486,17 +486,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PartnerServers.Any() || hasPropertyOverride) { - builder.Append(" partnerServers:"); + builder.Append(" partnerServers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PartnerServers) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " partnerServers: "); } builder.AppendLine(" ]"); } @@ -508,14 +508,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FailoverDatabases.Any() || hasPropertyOverride) { - builder.Append(" databases:"); + builder.Append(" databases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in FailoverDatabases) { if (item == null) @@ -535,12 +535,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -561,13 +564,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/GeoBackupPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/GeoBackupPolicyData.Serialization.cs index 2379c37fb845d..bbd4f4791263f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/GeoBackupPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/GeoBackupPolicyData.Serialization.cs @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,35 +225,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -261,28 +261,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -291,35 +291,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.ToSerialString()}'"); + builder.AppendLine($"'{State.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageType), out propertyOverride); if (Optional.IsDefined(StorageType) || hasPropertyOverride) { - builder.Append(" storageType:"); + builder.Append(" storageType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageType}'''"); } else { - builder.AppendLine($" '{StorageType}'"); + builder.AppendLine($"'{StorageType}'"); } } } @@ -329,12 +329,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -355,13 +358,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/IPv6FirewallRuleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/IPv6FirewallRuleData.Serialization.cs index 0d462ae1760da..baf1bbc88c26d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/IPv6FirewallRuleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/IPv6FirewallRuleData.Serialization.cs @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,14 +193,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartIPv6Address), out propertyOverride); if (Optional.IsDefined(StartIPv6Address) || hasPropertyOverride) { - builder.Append(" startIPv6Address:"); + builder.Append(" startIPv6Address: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartIPv6Address.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartIPv6Address}'''"); } else { - builder.AppendLine($" '{StartIPv6Address}'"); + builder.AppendLine($"'{StartIPv6Address}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndIPv6Address), out propertyOverride); if (Optional.IsDefined(EndIPv6Address) || hasPropertyOverride) { - builder.Append(" endIPv6Address:"); + builder.Append(" endIPv6Address: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndIPv6Address.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndIPv6Address}'''"); } else { - builder.AppendLine($" '{EndIPv6Address}'"); + builder.AppendLine($"'{EndIPv6Address}'"); } } } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstanceFailoverGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstanceFailoverGroupData.Serialization.cs index a9be76940adc6..69a63bfefd48a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstanceFailoverGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstanceFailoverGroupData.Serialization.cs @@ -200,7 +200,7 @@ internal static InstanceFailoverGroupData DeserializeInstanceFailoverGroupData(J { continue; } - readWriteEndpoint = InstanceFailoverGroupReadWriteEndpoint.DeserializeInstanceFailoverGroupReadWriteEndpoint(property0.Value, options); + readWriteEndpoint = InstanceFailoverGroupReadWriteEndpoint.DeserializeInstanceFailoverGroupReadWriteEndpoint(property0.Value); continue; } if (property0.NameEquals("readOnlyEndpoint"u8)) @@ -209,7 +209,7 @@ internal static InstanceFailoverGroupData DeserializeInstanceFailoverGroupData(J { continue; } - readOnlyEndpoint = InstanceFailoverGroupReadOnlyEndpoint.DeserializeInstanceFailoverGroupReadOnlyEndpoint(property0.Value, options); + readOnlyEndpoint = InstanceFailoverGroupReadOnlyEndpoint.DeserializeInstanceFailoverGroupReadOnlyEndpoint(property0.Value); continue; } if (property0.NameEquals("replicationRole"u8)) @@ -235,7 +235,7 @@ internal static InstanceFailoverGroupData DeserializeInstanceFailoverGroupData(J List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PartnerRegionInfo.DeserializePartnerRegionInfo(item, options)); + array.Add(PartnerRegionInfo.DeserializePartnerRegionInfo(item)); } partnerRegions = array; continue; @@ -249,7 +249,7 @@ internal static InstanceFailoverGroupData DeserializeInstanceFailoverGroupData(J List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedInstancePairInfo.DeserializeManagedInstancePairInfo(item, options)); + array.Add(ManagedInstancePairInfo.DeserializeManagedInstancePairInfo(item)); } managedInstancePairs = array; continue; @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -302,28 +302,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -332,77 +332,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondaryType), out propertyOverride); if (Optional.IsDefined(SecondaryType) || hasPropertyOverride) { - builder.Append(" secondaryType:"); + builder.Append(" secondaryType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SecondaryType.Value.ToString()}'"); + builder.AppendLine($"'{SecondaryType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadWriteEndpoint), out propertyOverride); if (Optional.IsDefined(ReadWriteEndpoint) || hasPropertyOverride) { - builder.Append(" readWriteEndpoint:"); + builder.Append(" readWriteEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ReadWriteEndpoint, options, 4, false); + AppendChildObject(builder, ReadWriteEndpoint, options, 4, false, " readWriteEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadOnlyEndpoint), out propertyOverride); if (Optional.IsDefined(ReadOnlyEndpoint) || hasPropertyOverride) { - builder.Append(" readOnlyEndpoint:"); + builder.Append(" readOnlyEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ReadOnlyEndpoint, options, 4, false); + AppendChildObject(builder, ReadOnlyEndpoint, options, 4, false, " readOnlyEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) { - builder.Append(" replicationRole:"); + builder.Append(" replicationRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationRole.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationRole.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationState), out propertyOverride); if (Optional.IsDefined(ReplicationState) || hasPropertyOverride) { - builder.Append(" replicationState:"); + builder.Append(" replicationState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ReplicationState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ReplicationState}'''"); } else { - builder.AppendLine($" '{ReplicationState}'"); + builder.AppendLine($"'{ReplicationState}'"); } } } @@ -412,17 +412,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PartnerRegions.Any() || hasPropertyOverride) { - builder.Append(" partnerRegions:"); + builder.Append(" partnerRegions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PartnerRegions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " partnerRegions: "); } builder.AppendLine(" ]"); } @@ -434,17 +434,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagedInstancePairs.Any() || hasPropertyOverride) { - builder.Append(" managedInstancePairs:"); + builder.Append(" managedInstancePairs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagedInstancePairs) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " managedInstancePairs: "); } builder.AppendLine(" ]"); } @@ -456,12 +456,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -482,13 +485,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePoolData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePoolData.Serialization.cs index ce1a1d8728d0b..8e2c1e3f4f950 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePoolData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePoolData.Serialization.cs @@ -157,7 +157,7 @@ internal static InstancePoolData DeserializeInstancePoolData(JsonElement element { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -301,14 +301,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -317,17 +317,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -335,12 +335,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -351,42 +351,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -395,63 +395,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetId), out propertyOverride); if (Optional.IsDefined(SubnetId) || hasPropertyOverride) { - builder.Append(" subnetId:"); + builder.Append(" subnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetId.ToString()}'"); + builder.AppendLine($"'{SubnetId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); if (Optional.IsDefined(VCores) || hasPropertyOverride) { - builder.Append(" vCores:"); + builder.Append(" vCores: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VCores.Value}"); + builder.AppendLine($"{VCores.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LicenseType), out propertyOverride); if (Optional.IsDefined(LicenseType) || hasPropertyOverride) { - builder.Append(" licenseType:"); + builder.Append(" licenseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LicenseType.Value.ToString()}'"); + builder.AppendLine($"'{LicenseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsZone), out propertyOverride); if (Optional.IsDefined(DnsZone) || hasPropertyOverride) { - builder.Append(" dnsZone:"); + builder.Append(" dnsZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsZone}'''"); } else { - builder.AppendLine($" '{DnsZone}'"); + builder.AppendLine($"'{DnsZone}'"); } } } @@ -459,14 +459,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaintenanceConfigurationId), out propertyOverride); if (Optional.IsDefined(MaintenanceConfigurationId) || hasPropertyOverride) { - builder.Append(" maintenanceConfigurationId:"); + builder.Append(" maintenanceConfigurationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaintenanceConfigurationId.ToString()}'"); + builder.AppendLine($"'{MaintenanceConfigurationId.ToString()}'"); } } @@ -475,12 +475,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -501,13 +504,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LedgerDigestUploadData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LedgerDigestUploadData.Serialization.cs index 7281278961a84..e8ff1b64f906e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LedgerDigestUploadData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LedgerDigestUploadData.Serialization.cs @@ -184,21 +184,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -206,28 +206,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DigestStorageEndpoint), out propertyOverride); if (Optional.IsDefined(DigestStorageEndpoint) || hasPropertyOverride) { - builder.Append(" digestStorageEndpoint:"); + builder.Append(" digestStorageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DigestStorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DigestStorageEndpoint}'''"); } else { - builder.AppendLine($" '{DigestStorageEndpoint}'"); + builder.AppendLine($"'{DigestStorageEndpoint}'"); } } } @@ -258,14 +258,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LogicalDatabaseTransparentDataEncryptionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LogicalDatabaseTransparentDataEncryptionData.Serialization.cs index 63e1589f8fa3a..5ae24a97ea3d0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LogicalDatabaseTransparentDataEncryptionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LogicalDatabaseTransparentDataEncryptionData.Serialization.cs @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionBackupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionBackupData.Serialization.cs index ded448c6dd84f..b51899806f247 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionBackupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionBackupData.Serialization.cs @@ -300,21 +300,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -322,28 +322,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -352,21 +352,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -374,36 +374,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerCreateOn), out propertyOverride); if (Optional.IsDefined(ServerCreateOn) || hasPropertyOverride) { - builder.Append(" serverCreateTime:"); + builder.Append(" serverCreateTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ServerCreateOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -411,102 +411,102 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseDeletedOn), out propertyOverride); if (Optional.IsDefined(DatabaseDeletedOn) || hasPropertyOverride) { - builder.Append(" databaseDeletionTime:"); + builder.Append(" databaseDeletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DatabaseDeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupOn), out propertyOverride); if (Optional.IsDefined(BackupOn) || hasPropertyOverride) { - builder.Append(" backupTime:"); + builder.Append(" backupTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(BackupOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupExpireOn), out propertyOverride); if (Optional.IsDefined(BackupExpireOn) || hasPropertyOverride) { - builder.Append(" backupExpirationTime:"); + builder.Append(" backupExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(BackupExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(BackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" backupStorageRedundancy:"); + builder.Append(" backupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{BackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(RequestedBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" requestedBackupStorageRedundancy:"); + builder.Append(" requestedBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestedBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{RequestedBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsBackupImmutable), out propertyOverride); if (Optional.IsDefined(IsBackupImmutable) || hasPropertyOverride) { - builder.Append(" isBackupImmutable:"); + builder.Append(" isBackupImmutable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsBackupImmutable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupStorageAccessTier), out propertyOverride); if (Optional.IsDefined(BackupStorageAccessTier) || hasPropertyOverride) { - builder.Append(" backupStorageAccessTier:"); + builder.Append(" backupStorageAccessTier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BackupStorageAccessTier.Value.ToString()}'"); + builder.AppendLine($"'{BackupStorageAccessTier.Value.ToString()}'"); } } @@ -515,12 +515,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -541,13 +544,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionPolicyData.Serialization.cs index 442cf9f4a87bd..6400eeed5ce68 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongTermRetentionPolicyData.Serialization.cs @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -258,28 +258,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -288,50 +288,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MakeBackupsImmutable), out propertyOverride); if (Optional.IsDefined(MakeBackupsImmutable) || hasPropertyOverride) { - builder.Append(" makeBackupsImmutable:"); + builder.Append(" makeBackupsImmutable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = MakeBackupsImmutable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupStorageAccessTier), out propertyOverride); if (Optional.IsDefined(BackupStorageAccessTier) || hasPropertyOverride) { - builder.Append(" backupStorageAccessTier:"); + builder.Append(" backupStorageAccessTier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BackupStorageAccessTier.Value.ToString()}'"); + builder.AppendLine($"'{BackupStorageAccessTier.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WeeklyRetention), out propertyOverride); if (Optional.IsDefined(WeeklyRetention) || hasPropertyOverride) { - builder.Append(" weeklyRetention:"); + builder.Append(" weeklyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WeeklyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WeeklyRetention}'''"); } else { - builder.AppendLine($" '{WeeklyRetention}'"); + builder.AppendLine($"'{WeeklyRetention}'"); } } } @@ -339,21 +339,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MonthlyRetention), out propertyOverride); if (Optional.IsDefined(MonthlyRetention) || hasPropertyOverride) { - builder.Append(" monthlyRetention:"); + builder.Append(" monthlyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MonthlyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MonthlyRetention}'''"); } else { - builder.AppendLine($" '{MonthlyRetention}'"); + builder.AppendLine($"'{MonthlyRetention}'"); } } } @@ -361,21 +361,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(YearlyRetention), out propertyOverride); if (Optional.IsDefined(YearlyRetention) || hasPropertyOverride) { - builder.Append(" yearlyRetention:"); + builder.Append(" yearlyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (YearlyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{YearlyRetention}'''"); } else { - builder.AppendLine($" '{YearlyRetention}'"); + builder.AppendLine($"'{YearlyRetention}'"); } } } @@ -383,14 +383,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WeekOfYear), out propertyOverride); if (Optional.IsDefined(WeekOfYear) || hasPropertyOverride) { - builder.Append(" weekOfYear:"); + builder.Append(" weekOfYear: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {WeekOfYear.Value}"); + builder.AppendLine($"{WeekOfYear.Value}"); } } @@ -399,12 +399,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -425,13 +428,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowOptionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowOptionData.Serialization.cs index b46783eb68fc1..49501c2e46e43 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowOptionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowOptionData.Serialization.cs @@ -198,7 +198,7 @@ internal static MaintenanceWindowOptionData DeserializeMaintenanceWindowOptionDa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(MaintenanceWindowTimeRange.DeserializeMaintenanceWindowTimeRange(item, options)); + array.Add(MaintenanceWindowTimeRange.DeserializeMaintenanceWindowTimeRange(item)); } maintenanceWindowCycles = array; continue; @@ -274,21 +274,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -296,28 +296,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -326,15 +326,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" isEnabled:"); + builder.Append(" isEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -343,17 +343,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MaintenanceWindowCycles.Any() || hasPropertyOverride) { - builder.Append(" maintenanceWindowCycles:"); + builder.Append(" maintenanceWindowCycles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MaintenanceWindowCycles) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " maintenanceWindowCycles: "); } builder.AppendLine(" ]"); } @@ -363,71 +363,71 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinDurationInMinutes), out propertyOverride); if (Optional.IsDefined(MinDurationInMinutes) || hasPropertyOverride) { - builder.Append(" minDurationInMinutes:"); + builder.Append(" minDurationInMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinDurationInMinutes.Value}"); + builder.AppendLine($"{MinDurationInMinutes.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDurationInMinutes), out propertyOverride); if (Optional.IsDefined(DefaultDurationInMinutes) || hasPropertyOverride) { - builder.Append(" defaultDurationInMinutes:"); + builder.Append(" defaultDurationInMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DefaultDurationInMinutes.Value}"); + builder.AppendLine($"{DefaultDurationInMinutes.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCycles), out propertyOverride); if (Optional.IsDefined(MinCycles) || hasPropertyOverride) { - builder.Append(" minCycles:"); + builder.Append(" minCycles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinCycles.Value}"); + builder.AppendLine($"{MinCycles.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGranularityInMinutes), out propertyOverride); if (Optional.IsDefined(TimeGranularityInMinutes) || hasPropertyOverride) { - builder.Append(" timeGranularityInMinutes:"); + builder.Append(" timeGranularityInMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TimeGranularityInMinutes.Value}"); + builder.AppendLine($"{TimeGranularityInMinutes.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowMultipleMaintenanceWindowsPerCycle), out propertyOverride); if (Optional.IsDefined(AllowMultipleMaintenanceWindowsPerCycle) || hasPropertyOverride) { - builder.Append(" allowMultipleMaintenanceWindowsPerCycle:"); + builder.Append(" allowMultipleMaintenanceWindowsPerCycle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowMultipleMaintenanceWindowsPerCycle.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -436,12 +436,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -462,13 +465,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowsData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowsData.Serialization.cs index 64086d6b24bd1..a1add9bb08fa7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowsData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/MaintenanceWindowsData.Serialization.cs @@ -153,7 +153,7 @@ internal static MaintenanceWindowsData DeserializeMaintenanceWindowsData(JsonEle List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(MaintenanceWindowTimeRange.DeserializeMaintenanceWindowTimeRange(item, options)); + array.Add(MaintenanceWindowTimeRange.DeserializeMaintenanceWindowTimeRange(item)); } timeRanges = array; continue; @@ -184,21 +184,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -206,28 +206,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -238,17 +238,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TimeRanges.Any() || hasPropertyOverride) { - builder.Append(" timeRanges:"); + builder.Append(" timeRanges: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TimeRanges) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " timeRanges: "); } builder.AppendLine(" ]"); } @@ -260,12 +260,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -286,13 +289,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedBackupShortTermRetentionPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedBackupShortTermRetentionPolicyData.Serialization.cs index c6be1a3987ab8..f9b0fe6fd2294 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedBackupShortTermRetentionPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedBackupShortTermRetentionPolicyData.Serialization.cs @@ -172,21 +172,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -194,28 +194,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -224,14 +224,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } @@ -240,12 +240,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -266,13 +269,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseAdvancedThreatProtectionData.Serialization.cs index 72109bb8fa38b..91a4b0db4e29c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseAdvancedThreatProtectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseAdvancedThreatProtectionData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseData.Serialization.cs index f7d62a998a509..1f7728c3c82ae 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseData.Serialization.cs @@ -507,21 +507,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -529,14 +529,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -545,17 +545,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -563,12 +563,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -579,28 +579,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -609,21 +609,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Collation), out propertyOverride); if (Optional.IsDefined(Collation) || hasPropertyOverride) { - builder.Append(" collation:"); + builder.Append(" collation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Collation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Collation}'''"); } else { - builder.AppendLine($" '{Collation}'"); + builder.AppendLine($"'{Collation}'"); } } } @@ -631,192 +631,192 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestorePoint), out propertyOverride); if (Optional.IsDefined(EarliestRestorePoint) || hasPropertyOverride) { - builder.Append(" earliestRestorePoint:"); + builder.Append(" earliestRestorePoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EarliestRestorePoint.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointInTime), out propertyOverride); if (Optional.IsDefined(RestorePointInTime) || hasPropertyOverride) { - builder.Append(" restorePointInTime:"); + builder.Append(" restorePointInTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestorePointInTime.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultSecondaryLocation), out propertyOverride); if (Optional.IsDefined(DefaultSecondaryLocation) || hasPropertyOverride) { - builder.Append(" defaultSecondaryLocation:"); + builder.Append(" defaultSecondaryLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultSecondaryLocation.Value.ToString()}'"); + builder.AppendLine($"'{DefaultSecondaryLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CatalogCollation), out propertyOverride); if (Optional.IsDefined(CatalogCollation) || hasPropertyOverride) { - builder.Append(" catalogCollation:"); + builder.Append(" catalogCollation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CatalogCollation.Value.ToString()}'"); + builder.AppendLine($"'{CatalogCollation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); if (Optional.IsDefined(CreateMode) || hasPropertyOverride) { - builder.Append(" createMode:"); + builder.Append(" createMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateMode.Value.ToString()}'"); + builder.AppendLine($"'{CreateMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerUri), out propertyOverride); if (Optional.IsDefined(StorageContainerUri) || hasPropertyOverride) { - builder.Append(" storageContainerUri:"); + builder.Append(" storageContainerUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageContainerUri.AbsoluteUri}'"); + builder.AppendLine($"'{StorageContainerUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceDatabaseId), out propertyOverride); if (Optional.IsDefined(SourceDatabaseId) || hasPropertyOverride) { - builder.Append(" sourceDatabaseId:"); + builder.Append(" sourceDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceDatabaseId.ToString()}'"); + builder.AppendLine($"'{SourceDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CrossSubscriptionSourceDatabaseId), out propertyOverride); if (Optional.IsDefined(CrossSubscriptionSourceDatabaseId) || hasPropertyOverride) { - builder.Append(" crossSubscriptionSourceDatabaseId:"); + builder.Append(" crossSubscriptionSourceDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CrossSubscriptionSourceDatabaseId.ToString()}'"); + builder.AppendLine($"'{CrossSubscriptionSourceDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorableDroppedDatabaseId), out propertyOverride); if (Optional.IsDefined(RestorableDroppedDatabaseId) || hasPropertyOverride) { - builder.Append(" restorableDroppedDatabaseId:"); + builder.Append(" restorableDroppedDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RestorableDroppedDatabaseId.ToString()}'"); + builder.AppendLine($"'{RestorableDroppedDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CrossSubscriptionRestorableDroppedDatabaseId), out propertyOverride); if (Optional.IsDefined(CrossSubscriptionRestorableDroppedDatabaseId) || hasPropertyOverride) { - builder.Append(" crossSubscriptionRestorableDroppedDatabaseId:"); + builder.Append(" crossSubscriptionRestorableDroppedDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CrossSubscriptionRestorableDroppedDatabaseId.ToString()}'"); + builder.AppendLine($"'{CrossSubscriptionRestorableDroppedDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerIdentity), out propertyOverride); if (Optional.IsDefined(StorageContainerIdentity) || hasPropertyOverride) { - builder.Append(" storageContainerIdentity:"); + builder.Append(" storageContainerIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerIdentity}'''"); } else { - builder.AppendLine($" '{StorageContainerIdentity}'"); + builder.AppendLine($"'{StorageContainerIdentity}'"); } } } @@ -824,21 +824,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerSasToken), out propertyOverride); if (Optional.IsDefined(StorageContainerSasToken) || hasPropertyOverride) { - builder.Append(" storageContainerSasToken:"); + builder.Append(" storageContainerSasToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerSasToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerSasToken}'''"); } else { - builder.AppendLine($" '{StorageContainerSasToken}'"); + builder.AppendLine($"'{StorageContainerSasToken}'"); } } } @@ -846,78 +846,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverGroupId), out propertyOverride); if (Optional.IsDefined(FailoverGroupId) || hasPropertyOverride) { - builder.Append(" failoverGroupId:"); + builder.Append(" failoverGroupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverGroupId.ToString()}'"); + builder.AppendLine($"'{FailoverGroupId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoverableDatabaseId), out propertyOverride); if (Optional.IsDefined(RecoverableDatabaseId) || hasPropertyOverride) { - builder.Append(" recoverableDatabaseId:"); + builder.Append(" recoverableDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RecoverableDatabaseId.ToString()}'"); + builder.AppendLine($"'{RecoverableDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LongTermRetentionBackupResourceId), out propertyOverride); if (Optional.IsDefined(LongTermRetentionBackupResourceId) || hasPropertyOverride) { - builder.Append(" longTermRetentionBackupResourceId:"); + builder.Append(" longTermRetentionBackupResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LongTermRetentionBackupResourceId.ToString()}'"); + builder.AppendLine($"'{LongTermRetentionBackupResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowAutoCompleteRestore), out propertyOverride); if (Optional.IsDefined(AllowAutoCompleteRestore) || hasPropertyOverride) { - builder.Append(" autoCompleteRestore:"); + builder.Append(" autoCompleteRestore: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowAutoCompleteRestore.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastBackupName), out propertyOverride); if (Optional.IsDefined(LastBackupName) || hasPropertyOverride) { - builder.Append(" lastBackupName:"); + builder.Append(" lastBackupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastBackupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastBackupName}'''"); } else { - builder.AppendLine($" '{LastBackupName}'"); + builder.AppendLine($"'{LastBackupName}'"); } } } @@ -925,29 +925,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CrossSubscriptionTargetManagedInstanceId), out propertyOverride); if (Optional.IsDefined(CrossSubscriptionTargetManagedInstanceId) || hasPropertyOverride) { - builder.Append(" crossSubscriptionTargetManagedInstanceId:"); + builder.Append(" crossSubscriptionTargetManagedInstanceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CrossSubscriptionTargetManagedInstanceId.ToString()}'"); + builder.AppendLine($"'{CrossSubscriptionTargetManagedInstanceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLedgerOn), out propertyOverride); if (Optional.IsDefined(IsLedgerOn) || hasPropertyOverride) { - builder.Append(" isLedgerOn:"); + builder.Append(" isLedgerOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLedgerOn.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -956,12 +956,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -982,13 +985,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseRestoreDetailData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseRestoreDetailData.Serialization.cs index c23be3bf6f91e..ed133f2aedec0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseRestoreDetailData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseRestoreDetailData.Serialization.cs @@ -428,7 +428,7 @@ internal static ManagedDatabaseRestoreDetailData DeserializeManagedDatabaseResto List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item, options)); + array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item)); } fullBackupSets = array; continue; @@ -442,7 +442,7 @@ internal static ManagedDatabaseRestoreDetailData DeserializeManagedDatabaseResto List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item, options)); + array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item)); } diffBackupSets = array; continue; @@ -456,7 +456,7 @@ internal static ManagedDatabaseRestoreDetailData DeserializeManagedDatabaseResto List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item, options)); + array.Add(ManagedDatabaseRestoreDetailBackupSetProperties.DeserializeManagedDatabaseRestoreDetailBackupSetProperties(item)); } logBackupSets = array; continue; @@ -470,7 +470,7 @@ internal static ManagedDatabaseRestoreDetailData DeserializeManagedDatabaseResto List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedDatabaseRestoreDetailUnrestorableFileProperties.DeserializeManagedDatabaseRestoreDetailUnrestorableFileProperties(item, options)); + array.Add(ManagedDatabaseRestoreDetailUnrestorableFileProperties.DeserializeManagedDatabaseRestoreDetailUnrestorableFileProperties(item)); } unrestorableFiles = array; continue; @@ -501,21 +501,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -523,28 +523,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -553,21 +553,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoreType), out propertyOverride); if (Optional.IsDefined(RestoreType) || hasPropertyOverride) { - builder.Append(" type:"); + builder.Append(" type: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RestoreType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RestoreType}'''"); } else { - builder.AppendLine($" '{RestoreType}'"); + builder.AppendLine($"'{RestoreType}'"); } } } @@ -575,21 +575,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -597,21 +597,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlockReason), out propertyOverride); if (Optional.IsDefined(BlockReason) || hasPropertyOverride) { - builder.Append(" blockReason:"); + builder.Append(" blockReason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BlockReason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BlockReason}'''"); } else { - builder.AppendLine($" '{BlockReason}'"); + builder.AppendLine($"'{BlockReason}'"); } } } @@ -619,21 +619,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUploadedFileName), out propertyOverride); if (Optional.IsDefined(LastUploadedFileName) || hasPropertyOverride) { - builder.Append(" lastUploadedFileName:"); + builder.Append(" lastUploadedFileName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastUploadedFileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastUploadedFileName}'''"); } else { - builder.AppendLine($" '{LastUploadedFileName}'"); + builder.AppendLine($"'{LastUploadedFileName}'"); } } } @@ -641,36 +641,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUploadedFileOn), out propertyOverride); if (Optional.IsDefined(LastUploadedFileOn) || hasPropertyOverride) { - builder.Append(" lastUploadedFileTime:"); + builder.Append(" lastUploadedFileTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastUploadedFileOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRestoredFileName), out propertyOverride); if (Optional.IsDefined(LastRestoredFileName) || hasPropertyOverride) { - builder.Append(" lastRestoredFileName:"); + builder.Append(" lastRestoredFileName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastRestoredFileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastRestoredFileName}'''"); } else { - builder.AppendLine($" '{LastRestoredFileName}'"); + builder.AppendLine($"'{LastRestoredFileName}'"); } } } @@ -678,78 +678,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRestoredFileOn), out propertyOverride); if (Optional.IsDefined(LastRestoredFileOn) || hasPropertyOverride) { - builder.Append(" lastRestoredFileTime:"); + builder.Append(" lastRestoredFileTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastRestoredFileOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CompletedPercent), out propertyOverride); if (Optional.IsDefined(CompletedPercent) || hasPropertyOverride) { - builder.Append(" percentCompleted:"); + builder.Append(" percentCompleted: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CompletedPercent.Value}"); + builder.AppendLine($"{CompletedPercent.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentRestoredSizeInMB), out propertyOverride); if (Optional.IsDefined(CurrentRestoredSizeInMB) || hasPropertyOverride) { - builder.Append(" currentRestoredSizeMB:"); + builder.Append(" currentRestoredSizeMB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentRestoredSizeInMB.Value}"); + builder.AppendLine($"{CurrentRestoredSizeInMB.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentRestorePlanSizeInMB), out propertyOverride); if (Optional.IsDefined(CurrentRestorePlanSizeInMB) || hasPropertyOverride) { - builder.Append(" currentRestorePlanSizeMB:"); + builder.Append(" currentRestorePlanSizeMB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentRestorePlanSizeInMB.Value}"); + builder.AppendLine($"{CurrentRestorePlanSizeInMB.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentBackupType), out propertyOverride); if (Optional.IsDefined(CurrentBackupType) || hasPropertyOverride) { - builder.Append(" currentBackupType:"); + builder.Append(" currentBackupType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentBackupType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentBackupType}'''"); } else { - builder.AppendLine($" '{CurrentBackupType}'"); + builder.AppendLine($"'{CurrentBackupType}'"); } } } @@ -757,21 +757,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentRestoringFileName), out propertyOverride); if (Optional.IsDefined(CurrentRestoringFileName) || hasPropertyOverride) { - builder.Append(" currentRestoringFileName:"); + builder.Append(" currentRestoringFileName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentRestoringFileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentRestoringFileName}'''"); } else { - builder.AppendLine($" '{CurrentRestoringFileName}'"); + builder.AppendLine($"'{CurrentRestoringFileName}'"); } } } @@ -779,84 +779,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesFound), out propertyOverride); if (Optional.IsDefined(NumberOfFilesFound) || hasPropertyOverride) { - builder.Append(" numberOfFilesDetected:"); + builder.Append(" numberOfFilesDetected: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesFound.Value}"); + builder.AppendLine($"{NumberOfFilesFound.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesQueued), out propertyOverride); if (Optional.IsDefined(NumberOfFilesQueued) || hasPropertyOverride) { - builder.Append(" numberOfFilesQueued:"); + builder.Append(" numberOfFilesQueued: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesQueued.Value}"); + builder.AppendLine($"{NumberOfFilesQueued.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesSkipped), out propertyOverride); if (Optional.IsDefined(NumberOfFilesSkipped) || hasPropertyOverride) { - builder.Append(" numberOfFilesSkipped:"); + builder.Append(" numberOfFilesSkipped: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesSkipped.Value}"); + builder.AppendLine($"{NumberOfFilesSkipped.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesRestoring), out propertyOverride); if (Optional.IsDefined(NumberOfFilesRestoring) || hasPropertyOverride) { - builder.Append(" numberOfFilesRestoring:"); + builder.Append(" numberOfFilesRestoring: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesRestoring.Value}"); + builder.AppendLine($"{NumberOfFilesRestoring.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesRestored), out propertyOverride); if (Optional.IsDefined(NumberOfFilesRestored) || hasPropertyOverride) { - builder.Append(" numberOfFilesRestored:"); + builder.Append(" numberOfFilesRestored: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesRestored.Value}"); + builder.AppendLine($"{NumberOfFilesRestored.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFilesUnrestorable), out propertyOverride); if (Optional.IsDefined(NumberOfFilesUnrestorable) || hasPropertyOverride) { - builder.Append(" numberOfFilesUnrestorable:"); + builder.Append(" numberOfFilesUnrestorable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFilesUnrestorable.Value}"); + builder.AppendLine($"{NumberOfFilesUnrestorable.Value}"); } } @@ -865,17 +865,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FullBackupSets.Any() || hasPropertyOverride) { - builder.Append(" fullBackupSets:"); + builder.Append(" fullBackupSets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in FullBackupSets) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " fullBackupSets: "); } builder.AppendLine(" ]"); } @@ -887,17 +887,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DiffBackupSets.Any() || hasPropertyOverride) { - builder.Append(" diffBackupSets:"); + builder.Append(" diffBackupSets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DiffBackupSets) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " diffBackupSets: "); } builder.AppendLine(" ]"); } @@ -909,17 +909,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LogBackupSets.Any() || hasPropertyOverride) { - builder.Append(" logBackupSets:"); + builder.Append(" logBackupSets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LogBackupSets) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " logBackupSets: "); } builder.AppendLine(" ]"); } @@ -931,17 +931,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UnrestorableFileList.Any() || hasPropertyOverride) { - builder.Append(" unrestorableFiles:"); + builder.Append(" unrestorableFiles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UnrestorableFileList) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " unrestorableFiles: "); } builder.AppendLine(" ]"); } @@ -953,12 +953,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -979,13 +982,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseSecurityAlertPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseSecurityAlertPolicyData.Serialization.cs index 93c63c63349d9..e66c253921abb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseSecurityAlertPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedDatabaseSecurityAlertPolicyData.Serialization.cs @@ -291,21 +291,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -313,28 +313,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -343,14 +343,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -359,14 +359,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DisabledAlerts.Any() || hasPropertyOverride) { - builder.Append(" disabledAlerts:"); + builder.Append(" disabledAlerts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DisabledAlerts) { if (item == null) @@ -394,14 +394,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EmailAddresses.Any() || hasPropertyOverride) { - builder.Append(" emailAddresses:"); + builder.Append(" emailAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EmailAddresses) { if (item == null) @@ -427,36 +427,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendToEmailAccountAdmins), out propertyOverride); if (Optional.IsDefined(SendToEmailAccountAdmins) || hasPropertyOverride) { - builder.Append(" emailAccountAdmins:"); + builder.Append(" emailAccountAdmins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SendToEmailAccountAdmins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -464,21 +464,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -486,29 +486,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -517,12 +517,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -543,13 +546,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdministratorData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdministratorData.Serialization.cs index a8b01ffa105b8..1adaba3304678 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdministratorData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdministratorData.Serialization.cs @@ -214,21 +214,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -236,28 +236,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -266,35 +266,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) { - builder.Append(" administratorType:"); + builder.Append(" administratorType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AdministratorType.Value.ToString()}'"); + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Login.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Login}'''"); } else { - builder.AppendLine($" '{Login}'"); + builder.AppendLine($"'{Login}'"); } } } @@ -302,28 +302,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); if (Optional.IsDefined(Sid) || hasPropertyOverride) { - builder.Append(" sid:"); + builder.Append(" sid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Sid.Value.ToString()}'"); + builder.AppendLine($"'{Sid.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -332,12 +332,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -358,13 +361,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdvancedThreatProtectionData.Serialization.cs index c7a5805e0bcb9..4df3707f56464 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdvancedThreatProtectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAdvancedThreatProtectionData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAzureADOnlyAuthenticationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAzureADOnlyAuthenticationData.Serialization.cs index 0fe868c15719f..3bed23f65dbf8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAzureADOnlyAuthenticationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceAzureADOnlyAuthenticationData.Serialization.cs @@ -172,21 +172,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -194,28 +194,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -224,15 +224,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureADOnlyAuthenticationEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureADOnlyAuthenticationEnabled) || hasPropertyOverride) { - builder.Append(" azureADOnlyAuthentication:"); + builder.Append(" azureADOnlyAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureADOnlyAuthenticationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.Serialization.cs index 1f5aca338bc4b..cf23454db3844 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.Serialization.cs @@ -323,7 +323,7 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -539,7 +539,7 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedInstancePecProperty.DeserializeManagedInstancePecProperty(item, options)); + array.Add(ManagedInstancePecProperty.DeserializeManagedInstancePecProperty(item)); } privateEndpointConnections = array; continue; @@ -600,7 +600,7 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e { continue; } - administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value, options); + administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value); continue; } if (property0.NameEquals("servicePrincipal"u8)) @@ -609,7 +609,7 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e { continue; } - servicePrincipal = SqlServicePrincipal.DeserializeSqlServicePrincipal(property0.Value, options); + servicePrincipal = SqlServicePrincipal.DeserializeSqlServicePrincipal(property0.Value); continue; } } @@ -638,21 +638,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -660,14 +660,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -676,17 +676,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -694,12 +694,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -710,56 +710,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -768,49 +768,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedInstanceCreateMode), out propertyOverride); if (Optional.IsDefined(ManagedInstanceCreateMode) || hasPropertyOverride) { - builder.Append(" managedInstanceCreateMode:"); + builder.Append(" managedInstanceCreateMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedInstanceCreateMode.Value.ToString()}'"); + builder.AppendLine($"'{ManagedInstanceCreateMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainName), out propertyOverride); if (Optional.IsDefined(FullyQualifiedDomainName) || hasPropertyOverride) { - builder.Append(" fullyQualifiedDomainName:"); + builder.Append(" fullyQualifiedDomainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FullyQualifiedDomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FullyQualifiedDomainName}'''"); } else { - builder.AppendLine($" '{FullyQualifiedDomainName}'"); + builder.AppendLine($"'{FullyQualifiedDomainName}'"); } } } @@ -818,21 +818,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLogin), out propertyOverride); if (Optional.IsDefined(AdministratorLogin) || hasPropertyOverride) { - builder.Append(" administratorLogin:"); + builder.Append(" administratorLogin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AdministratorLogin.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AdministratorLogin}'''"); } else { - builder.AppendLine($" '{AdministratorLogin}'"); + builder.AppendLine($"'{AdministratorLogin}'"); } } } @@ -840,21 +840,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLoginPassword), out propertyOverride); if (Optional.IsDefined(AdministratorLoginPassword) || hasPropertyOverride) { - builder.Append(" administratorLoginPassword:"); + builder.Append(" administratorLoginPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AdministratorLoginPassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AdministratorLoginPassword}'''"); } else { - builder.AppendLine($" '{AdministratorLoginPassword}'"); + builder.AppendLine($"'{AdministratorLoginPassword}'"); } } } @@ -862,35 +862,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetId), out propertyOverride); if (Optional.IsDefined(SubnetId) || hasPropertyOverride) { - builder.Append(" subnetId:"); + builder.Append(" subnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetId.ToString()}'"); + builder.AppendLine($"'{SubnetId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -898,63 +898,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LicenseType), out propertyOverride); if (Optional.IsDefined(LicenseType) || hasPropertyOverride) { - builder.Append(" licenseType:"); + builder.Append(" licenseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LicenseType.Value.ToString()}'"); + builder.AppendLine($"'{LicenseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); if (Optional.IsDefined(VCores) || hasPropertyOverride) { - builder.Append(" vCores:"); + builder.Append(" vCores: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VCores.Value}"); + builder.AppendLine($"{VCores.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageSizeInGB), out propertyOverride); if (Optional.IsDefined(StorageSizeInGB) || hasPropertyOverride) { - builder.Append(" storageSizeInGB:"); + builder.Append(" storageSizeInGB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StorageSizeInGB.Value}"); + builder.AppendLine($"{StorageSizeInGB.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Collation), out propertyOverride); if (Optional.IsDefined(Collation) || hasPropertyOverride) { - builder.Append(" collation:"); + builder.Append(" collation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Collation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Collation}'''"); } else { - builder.AppendLine($" '{Collation}'"); + builder.AppendLine($"'{Collation}'"); } } } @@ -962,21 +962,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsZone), out propertyOverride); if (Optional.IsDefined(DnsZone) || hasPropertyOverride) { - builder.Append(" dnsZone:"); + builder.Append(" dnsZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsZone}'''"); } else { - builder.AppendLine($" '{DnsZone}'"); + builder.AppendLine($"'{DnsZone}'"); } } } @@ -984,93 +984,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedDnsZonePartner), out propertyOverride); if (Optional.IsDefined(ManagedDnsZonePartner) || hasPropertyOverride) { - builder.Append(" dnsZonePartner:"); + builder.Append(" dnsZonePartner: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedDnsZonePartner.ToString()}'"); + builder.AppendLine($"'{ManagedDnsZonePartner.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPublicDataEndpointEnabled), out propertyOverride); if (Optional.IsDefined(IsPublicDataEndpointEnabled) || hasPropertyOverride) { - builder.Append(" publicDataEndpointEnabled:"); + builder.Append(" publicDataEndpointEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPublicDataEndpointEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceManagedInstanceId), out propertyOverride); if (Optional.IsDefined(SourceManagedInstanceId) || hasPropertyOverride) { - builder.Append(" sourceManagedInstanceId:"); + builder.Append(" sourceManagedInstanceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceManagedInstanceId.ToString()}'"); + builder.AppendLine($"'{SourceManagedInstanceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointInTime), out propertyOverride); if (Optional.IsDefined(RestorePointInTime) || hasPropertyOverride) { - builder.Append(" restorePointInTime:"); + builder.Append(" restorePointInTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestorePointInTime.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProxyOverride), out propertyOverride); if (Optional.IsDefined(ProxyOverride) || hasPropertyOverride) { - builder.Append(" proxyOverride:"); + builder.Append(" proxyOverride: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProxyOverride.Value.ToString()}'"); + builder.AppendLine($"'{ProxyOverride.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimezoneId), out propertyOverride); if (Optional.IsDefined(TimezoneId) || hasPropertyOverride) { - builder.Append(" timezoneId:"); + builder.Append(" timezoneId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimezoneId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimezoneId}'''"); } else { - builder.AppendLine($" '{TimezoneId}'"); + builder.AppendLine($"'{TimezoneId}'"); } } } @@ -1078,28 +1078,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InstancePoolId), out propertyOverride); if (Optional.IsDefined(InstancePoolId) || hasPropertyOverride) { - builder.Append(" instancePoolId:"); + builder.Append(" instancePoolId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InstancePoolId.ToString()}'"); + builder.AppendLine($"'{InstancePoolId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaintenanceConfigurationId), out propertyOverride); if (Optional.IsDefined(MaintenanceConfigurationId) || hasPropertyOverride) { - builder.Append(" maintenanceConfigurationId:"); + builder.Append(" maintenanceConfigurationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaintenanceConfigurationId.ToString()}'"); + builder.AppendLine($"'{MaintenanceConfigurationId.ToString()}'"); } } @@ -1108,17 +1108,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -1128,21 +1128,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimalTlsVersion), out propertyOverride); if (Optional.IsDefined(MinimalTlsVersion) || hasPropertyOverride) { - builder.Append(" minimalTlsVersion:"); + builder.Append(" minimalTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MinimalTlsVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MinimalTlsVersion}'''"); } else { - builder.AppendLine($" '{MinimalTlsVersion}'"); + builder.AppendLine($"'{MinimalTlsVersion}'"); } } } @@ -1150,99 +1150,99 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(CurrentBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" currentBackupStorageRedundancy:"); + builder.Append(" currentBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{CurrentBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(RequestedBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" requestedBackupStorageRedundancy:"); + builder.Append(" requestedBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestedBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{RequestedBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryUserAssignedIdentityId), out propertyOverride); if (Optional.IsDefined(PrimaryUserAssignedIdentityId) || hasPropertyOverride) { - builder.Append(" primaryUserAssignedIdentityId:"); + builder.Append(" primaryUserAssignedIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryUserAssignedIdentityId.ToString()}'"); + builder.AppendLine($"'{PrimaryUserAssignedIdentityId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyId), out propertyOverride); if (Optional.IsDefined(KeyId) || hasPropertyOverride) { - builder.Append(" keyId:"); + builder.Append(" keyId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyId.AbsoluteUri}'"); + builder.AppendLine($"'{KeyId.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Administrators), out propertyOverride); if (Optional.IsDefined(Administrators) || hasPropertyOverride) { - builder.Append(" administrators:"); + builder.Append(" administrators: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Administrators, options, 4, false); + AppendChildObject(builder, Administrators, options, 4, false, " administrators: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServicePrincipal), out propertyOverride); if (Optional.IsDefined(ServicePrincipal) || hasPropertyOverride) { - builder.Append(" servicePrincipal:"); + builder.Append(" servicePrincipal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ServicePrincipal, options, 4, false); + AppendChildObject(builder, ServicePrincipal, options, 4, false, " servicePrincipal: "); } } @@ -1251,12 +1251,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1277,13 +1280,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceDtcData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceDtcData.Serialization.cs index bce53d3d05724..b66797317956a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceDtcData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceDtcData.Serialization.cs @@ -183,7 +183,7 @@ internal static ManagedInstanceDtcData DeserializeManagedInstanceDtcData(JsonEle { continue; } - securitySettings = ManagedInstanceDtcSecuritySettings.DeserializeManagedInstanceDtcSecuritySettings(property0.Value, options); + securitySettings = ManagedInstanceDtcSecuritySettings.DeserializeManagedInstanceDtcSecuritySettings(property0.Value); continue; } if (property0.NameEquals("externalDnsSuffixSearchList"u8)) @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -262,28 +262,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -292,29 +292,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DtcEnabled), out propertyOverride); if (Optional.IsDefined(DtcEnabled) || hasPropertyOverride) { - builder.Append(" dtcEnabled:"); + builder.Append(" dtcEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = DtcEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecuritySettings), out propertyOverride); if (Optional.IsDefined(SecuritySettings) || hasPropertyOverride) { - builder.Append(" securitySettings:"); + builder.Append(" securitySettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SecuritySettings, options, 4, false); + AppendChildObject(builder, SecuritySettings, options, 4, false, " securitySettings: "); } } @@ -323,14 +323,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExternalDnsSuffixSearchList.Any() || hasPropertyOverride) { - builder.Append(" externalDnsSuffixSearchList:"); + builder.Append(" externalDnsSuffixSearchList: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExternalDnsSuffixSearchList) { if (item == null) @@ -356,21 +356,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DtcHostNameDnsSuffix), out propertyOverride); if (Optional.IsDefined(DtcHostNameDnsSuffix) || hasPropertyOverride) { - builder.Append(" dtcHostNameDnsSuffix:"); + builder.Append(" dtcHostNameDnsSuffix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DtcHostNameDnsSuffix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DtcHostNameDnsSuffix}'''"); } else { - builder.AppendLine($" '{DtcHostNameDnsSuffix}'"); + builder.AppendLine($"'{DtcHostNameDnsSuffix}'"); } } } @@ -378,14 +378,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -394,12 +394,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -420,13 +423,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceEncryptionProtectorData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceEncryptionProtectorData.Serialization.cs index 7e06e162a27ec..3e6ae9d08332b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceEncryptionProtectorData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceEncryptionProtectorData.Serialization.cs @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -280,28 +280,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -310,21 +310,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyName), out propertyOverride); if (Optional.IsDefined(ServerKeyName) || hasPropertyOverride) { - builder.Append(" serverKeyName:"); + builder.Append(" serverKeyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerKeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerKeyName}'''"); } else { - builder.AppendLine($" '{ServerKeyName}'"); + builder.AppendLine($"'{ServerKeyName}'"); } } } @@ -332,49 +332,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyType), out propertyOverride); if (Optional.IsDefined(ServerKeyType) || hasPropertyOverride) { - builder.Append(" serverKeyType:"); + builder.Append(" serverKeyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerKeyType.Value.ToString()}'"); + builder.AppendLine($"'{ServerKeyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -382,15 +382,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRotationEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoRotationEnabled) || hasPropertyOverride) { - builder.Append(" autoRotationEnabled:"); + builder.Append(" autoRotationEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRotationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -399,12 +399,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -425,13 +428,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceKeyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceKeyData.Serialization.cs index f1f8132d75d3a..21dfb6f47c6b8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceKeyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceKeyData.Serialization.cs @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -284,28 +284,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -314,49 +314,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyType), out propertyOverride); if (Optional.IsDefined(ServerKeyType) || hasPropertyOverride) { - builder.Append(" serverKeyType:"); + builder.Append(" serverKeyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerKeyType.Value.ToString()}'"); + builder.AppendLine($"'{ServerKeyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -364,30 +364,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRotationEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoRotationEnabled) || hasPropertyOverride) { - builder.Append(" autoRotationEnabled:"); + builder.Append(" autoRotationEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRotationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -396,12 +396,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -422,13 +425,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionBackupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionBackupData.Serialization.cs index 51dee0d0cc556..ee90ff93a2b7c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionBackupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionBackupData.Serialization.cs @@ -255,21 +255,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -277,28 +277,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -307,21 +307,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedInstanceName), out propertyOverride); if (Optional.IsDefined(ManagedInstanceName) || hasPropertyOverride) { - builder.Append(" managedInstanceName:"); + builder.Append(" managedInstanceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedInstanceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedInstanceName}'''"); } else { - builder.AppendLine($" '{ManagedInstanceName}'"); + builder.AppendLine($"'{ManagedInstanceName}'"); } } } @@ -329,36 +329,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedInstanceCreateOn), out propertyOverride); if (Optional.IsDefined(ManagedInstanceCreateOn) || hasPropertyOverride) { - builder.Append(" managedInstanceCreateTime:"); + builder.Append(" managedInstanceCreateTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ManagedInstanceCreateOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -366,59 +366,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseDeletedOn), out propertyOverride); if (Optional.IsDefined(DatabaseDeletedOn) || hasPropertyOverride) { - builder.Append(" databaseDeletionTime:"); + builder.Append(" databaseDeletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DatabaseDeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupOn), out propertyOverride); if (Optional.IsDefined(BackupOn) || hasPropertyOverride) { - builder.Append(" backupTime:"); + builder.Append(" backupTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(BackupOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupExpireOn), out propertyOverride); if (Optional.IsDefined(BackupExpireOn) || hasPropertyOverride) { - builder.Append(" backupExpirationTime:"); + builder.Append(" backupExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(BackupExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(BackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" backupStorageRedundancy:"); + builder.Append(" backupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{BackupStorageRedundancy.Value.ToString()}'"); } } @@ -427,12 +427,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -453,13 +456,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionPolicyData.Serialization.cs index b9d70445fc7d9..747b659d8ebe3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceLongTermRetentionPolicyData.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -257,21 +257,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WeeklyRetention), out propertyOverride); if (Optional.IsDefined(WeeklyRetention) || hasPropertyOverride) { - builder.Append(" weeklyRetention:"); + builder.Append(" weeklyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WeeklyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WeeklyRetention}'''"); } else { - builder.AppendLine($" '{WeeklyRetention}'"); + builder.AppendLine($"'{WeeklyRetention}'"); } } } @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MonthlyRetention), out propertyOverride); if (Optional.IsDefined(MonthlyRetention) || hasPropertyOverride) { - builder.Append(" monthlyRetention:"); + builder.Append(" monthlyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MonthlyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MonthlyRetention}'''"); } else { - builder.AppendLine($" '{MonthlyRetention}'"); + builder.AppendLine($"'{MonthlyRetention}'"); } } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(YearlyRetention), out propertyOverride); if (Optional.IsDefined(YearlyRetention) || hasPropertyOverride) { - builder.Append(" yearlyRetention:"); + builder.Append(" yearlyRetention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (YearlyRetention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{YearlyRetention}'''"); } else { - builder.AppendLine($" '{YearlyRetention}'"); + builder.AppendLine($"'{YearlyRetention}'"); } } } @@ -323,14 +323,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WeekOfYear), out propertyOverride); if (Optional.IsDefined(WeekOfYear) || hasPropertyOverride) { - builder.Append(" weekOfYear:"); + builder.Append(" weekOfYear: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {WeekOfYear.Value}"); + builder.AppendLine($"{WeekOfYear.Value}"); } } @@ -339,12 +339,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -365,13 +368,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceOperationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceOperationData.Serialization.cs index 3ed9018a04dbc..e97df4fa0dd75 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceOperationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceOperationData.Serialization.cs @@ -325,7 +325,7 @@ internal static ManagedInstanceOperationData DeserializeManagedInstanceOperation { continue; } - operationParameters = ManagedInstanceOperationParametersPair.DeserializeManagedInstanceOperationParametersPair(property0.Value, options); + operationParameters = ManagedInstanceOperationParametersPair.DeserializeManagedInstanceOperationParametersPair(property0.Value); continue; } if (property0.NameEquals("operationSteps"u8)) @@ -334,7 +334,7 @@ internal static ManagedInstanceOperationData DeserializeManagedInstanceOperation { continue; } - operationSteps = ManagedInstanceOperationSteps.DeserializeManagedInstanceOperationSteps(property0.Value, options); + operationSteps = ManagedInstanceOperationSteps.DeserializeManagedInstanceOperationSteps(property0.Value); continue; } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -385,28 +385,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -415,21 +415,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedInstanceName), out propertyOverride); if (Optional.IsDefined(ManagedInstanceName) || hasPropertyOverride) { - builder.Append(" managedInstanceName:"); + builder.Append(" managedInstanceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedInstanceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedInstanceName}'''"); } else { - builder.AppendLine($" '{ManagedInstanceName}'"); + builder.AppendLine($"'{ManagedInstanceName}'"); } } } @@ -437,21 +437,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -459,21 +459,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationFriendlyName), out propertyOverride); if (Optional.IsDefined(OperationFriendlyName) || hasPropertyOverride) { - builder.Append(" operationFriendlyName:"); + builder.Append(" operationFriendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationFriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationFriendlyName}'''"); } else { - builder.AppendLine($" '{OperationFriendlyName}'"); + builder.AppendLine($"'{OperationFriendlyName}'"); } } } @@ -481,78 +481,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDescription), out propertyOverride); if (Optional.IsDefined(ErrorDescription) || hasPropertyOverride) { - builder.Append(" errorDescription:"); + builder.Append(" errorDescription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorDescription}'''"); } else { - builder.AppendLine($" '{ErrorDescription}'"); + builder.AppendLine($"'{ErrorDescription}'"); } } } @@ -560,65 +560,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUserError), out propertyOverride); if (Optional.IsDefined(IsUserError) || hasPropertyOverride) { - builder.Append(" isUserError:"); + builder.Append(" isUserError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUserError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EstimatedCompleteOn), out propertyOverride); if (Optional.IsDefined(EstimatedCompleteOn) || hasPropertyOverride) { - builder.Append(" estimatedCompletionTime:"); + builder.Append(" estimatedCompletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EstimatedCompleteOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -626,43 +626,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsCancellable), out propertyOverride); if (Optional.IsDefined(IsCancellable) || hasPropertyOverride) { - builder.Append(" isCancellable:"); + builder.Append(" isCancellable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsCancellable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationParameters), out propertyOverride); if (Optional.IsDefined(OperationParameters) || hasPropertyOverride) { - builder.Append(" operationParameters:"); + builder.Append(" operationParameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, OperationParameters, options, 4, false); + AppendChildObject(builder, OperationParameters, options, 4, false, " operationParameters: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationSteps), out propertyOverride); if (Optional.IsDefined(OperationSteps) || hasPropertyOverride) { - builder.Append(" operationSteps:"); + builder.Append(" operationSteps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, OperationSteps, options, 4, false); + AppendChildObject(builder, OperationSteps, options, 4, false, " operationSteps: "); } } @@ -671,12 +671,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -697,13 +700,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateEndpointConnectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateEndpointConnectionData.Serialization.cs index ae0f1e2183714..94576d06d1a01 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateEndpointConnectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateEndpointConnectionData.Serialization.cs @@ -166,7 +166,7 @@ internal static ManagedInstancePrivateEndpointConnectionData DeserializeManagedI { continue; } - privateLinkServiceConnectionState = ManagedInstancePrivateLinkServiceConnectionStateProperty.DeserializeManagedInstancePrivateLinkServiceConnectionStateProperty(property0.Value, options); + privateLinkServiceConnectionState = ManagedInstancePrivateLinkServiceConnectionStateProperty.DeserializeManagedInstancePrivateLinkServiceConnectionStateProperty(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -200,21 +200,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -222,28 +222,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -252,49 +252,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -304,12 +304,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -330,13 +333,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateLinkData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateLinkData.Serialization.cs index 9a30a2deb7f55..149a089cfa226 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateLinkData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstancePrivateLinkData.Serialization.cs @@ -108,7 +108,7 @@ internal static ManagedInstancePrivateLinkData DeserializeManagedInstancePrivate { continue; } - properties = ManagedInstancePrivateLinkProperties.DeserializeManagedInstancePrivateLinkProperties(property.Value, options); + properties = ManagedInstancePrivateLinkProperties.DeserializeManagedInstancePrivateLinkProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,42 +180,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceServerConfigurationOptionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceServerConfigurationOptionData.Serialization.cs index 5d6dad7b00099..c783cb8118cac 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceServerConfigurationOptionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceServerConfigurationOptionData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,28 +240,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerConfigurationOptionValue), out propertyOverride); if (Optional.IsDefined(ServerConfigurationOptionValue) || hasPropertyOverride) { - builder.Append(" serverConfigurationOptionValue:"); + builder.Append(" serverConfigurationOptionValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ServerConfigurationOptionValue.Value}"); + builder.AppendLine($"{ServerConfigurationOptionValue.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -270,12 +270,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -296,13 +299,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceStartStopScheduleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceStartStopScheduleData.Serialization.cs index 7b76925ae5f8c..47ea7c2d691f7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceStartStopScheduleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceStartStopScheduleData.Serialization.cs @@ -187,7 +187,7 @@ internal static ManagedInstanceStartStopScheduleData DeserializeManagedInstanceS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SqlScheduleItem.DeserializeSqlScheduleItem(item, options)); + array.Add(SqlScheduleItem.DeserializeSqlScheduleItem(item)); } scheduleList = array; continue; @@ -228,21 +228,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -250,28 +250,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -302,21 +302,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeZoneId), out propertyOverride); if (Optional.IsDefined(TimeZoneId) || hasPropertyOverride) { - builder.Append(" timeZoneId:"); + builder.Append(" timeZoneId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeZoneId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeZoneId}'''"); } else { - builder.AppendLine($" '{TimeZoneId}'"); + builder.AppendLine($"'{TimeZoneId}'"); } } } @@ -326,17 +326,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ScheduleList.Any() || hasPropertyOverride) { - builder.Append(" scheduleList:"); + builder.Append(" scheduleList: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ScheduleList) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " scheduleList: "); } builder.AppendLine(" ]"); } @@ -346,21 +346,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextRunAction), out propertyOverride); if (Optional.IsDefined(NextRunAction) || hasPropertyOverride) { - builder.Append(" nextRunAction:"); + builder.Append(" nextRunAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextRunAction.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextRunAction}'''"); } else { - builder.AppendLine($" '{NextRunAction}'"); + builder.AppendLine($"'{NextRunAction}'"); } } } @@ -368,21 +368,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextExecutionTime), out propertyOverride); if (Optional.IsDefined(NextExecutionTime) || hasPropertyOverride) { - builder.Append(" nextExecutionTime:"); + builder.Append(" nextExecutionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextExecutionTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextExecutionTime}'''"); } else { - builder.AppendLine($" '{NextExecutionTime}'"); + builder.AppendLine($"'{NextExecutionTime}'"); } } } @@ -392,12 +392,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -418,13 +421,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceVulnerabilityAssessmentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceVulnerabilityAssessmentData.Serialization.cs index 5b2c75d054d3e..f5f7ed347f0b7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceVulnerabilityAssessmentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceVulnerabilityAssessmentData.Serialization.cs @@ -177,7 +177,7 @@ internal static ManagedInstanceVulnerabilityAssessmentData DeserializeManagedIns { continue; } - recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value, options); + recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value); continue; } } @@ -206,21 +206,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -228,28 +228,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerPath), out propertyOverride); if (Optional.IsDefined(StorageContainerPath) || hasPropertyOverride) { - builder.Append(" storageContainerPath:"); + builder.Append(" storageContainerPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerPath}'''"); } else { - builder.AppendLine($" '{StorageContainerPath}'"); + builder.AppendLine($"'{StorageContainerPath}'"); } } } @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerSasKey), out propertyOverride); if (Optional.IsDefined(StorageContainerSasKey) || hasPropertyOverride) { - builder.Append(" storageContainerSasKey:"); + builder.Append(" storageContainerSasKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerSasKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerSasKey}'''"); } else { - builder.AppendLine($" '{StorageContainerSasKey}'"); + builder.AppendLine($"'{StorageContainerSasKey}'"); } } } @@ -302,21 +302,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -324,14 +324,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecurringScans), out propertyOverride); if (Optional.IsDefined(RecurringScans) || hasPropertyOverride) { - builder.Append(" recurringScans:"); + builder.Append(" recurringScans: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RecurringScans, options, 4, false); + AppendChildObject(builder, RecurringScans, options, 4, false, " recurringScans: "); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedLedgerDigestUploadData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedLedgerDigestUploadData.Serialization.cs index 87d9f491d42b2..b5859a0efb1e6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedLedgerDigestUploadData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedLedgerDigestUploadData.Serialization.cs @@ -184,21 +184,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -206,28 +206,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DigestStorageEndpoint), out propertyOverride); if (Optional.IsDefined(DigestStorageEndpoint) || hasPropertyOverride) { - builder.Append(" digestStorageEndpoint:"); + builder.Append(" digestStorageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DigestStorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DigestStorageEndpoint}'''"); } else { - builder.AppendLine($" '{DigestStorageEndpoint}'"); + builder.AppendLine($"'{DigestStorageEndpoint}'"); } } } @@ -258,14 +258,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.Serialization.cs index 05dc8a46dcaed..79e58e5489608 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,28 +201,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureDnsRecord), out propertyOverride); if (Optional.IsDefined(AzureDnsRecord) || hasPropertyOverride) { - builder.Append(" azureDnsRecord:"); + builder.Append(" azureDnsRecord: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzureDnsRecord.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzureDnsRecord}'''"); } else { - builder.AppendLine($" '{AzureDnsRecord}'"); + builder.AppendLine($"'{AzureDnsRecord}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicAzureDnsRecord), out propertyOverride); if (Optional.IsDefined(PublicAzureDnsRecord) || hasPropertyOverride) { - builder.Append(" publicAzureDnsRecord:"); + builder.Append(" publicAzureDnsRecord: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicAzureDnsRecord.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicAzureDnsRecord}'''"); } else { - builder.AppendLine($" '{PublicAzureDnsRecord}'"); + builder.AppendLine($"'{PublicAzureDnsRecord}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerSecurityAlertPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerSecurityAlertPolicyData.Serialization.cs index 81c81a8388382..31dabf76b091d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerSecurityAlertPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerSecurityAlertPolicyData.Serialization.cs @@ -291,21 +291,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -313,28 +313,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -343,14 +343,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -359,14 +359,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DisabledAlerts.Any() || hasPropertyOverride) { - builder.Append(" disabledAlerts:"); + builder.Append(" disabledAlerts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DisabledAlerts) { if (item == null) @@ -394,14 +394,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EmailAddresses.Any() || hasPropertyOverride) { - builder.Append(" emailAddresses:"); + builder.Append(" emailAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EmailAddresses) { if (item == null) @@ -427,36 +427,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendToEmailAccountAdmins), out propertyOverride); if (Optional.IsDefined(SendToEmailAccountAdmins) || hasPropertyOverride) { - builder.Append(" emailAccountAdmins:"); + builder.Append(" emailAccountAdmins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SendToEmailAccountAdmins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -464,21 +464,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -486,29 +486,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -517,12 +517,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -543,13 +546,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedTransparentDataEncryptionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedTransparentDataEncryptionData.Serialization.cs index 20af7f0f8d71b..940c3cbef0055 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedTransparentDataEncryptionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedTransparentDataEncryptionData.Serialization.cs @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdministratorListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdministratorListResult.Serialization.cs index 6749204a64ecd..88a4e5bc2d09f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdministratorListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdministratorListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static AdministratorListResult DeserializeAdministratorListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerAzureADAdministratorData.DeserializeSqlServerAzureADAdministratorData(item, options)); + array.Add(SqlServerAzureADAdministratorData.DeserializeSqlServerAzureADAdministratorData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutoPauseDelayTimeRange.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutoPauseDelayTimeRange.Serialization.cs index aa3b41a8fa1d2..6620888b6e384 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutoPauseDelayTimeRange.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutoPauseDelayTimeRange.Serialization.cs @@ -183,84 +183,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinValue), out propertyOverride); if (Optional.IsDefined(MinValue) || hasPropertyOverride) { - builder.Append(" minValue:"); + builder.Append(" minValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinValue.Value}"); + builder.AppendLine($"{MinValue.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxValue), out propertyOverride); if (Optional.IsDefined(MaxValue) || hasPropertyOverride) { - builder.Append(" maxValue:"); + builder.Append(" maxValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxValue.Value}"); + builder.AppendLine($"{MaxValue.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StepSize), out propertyOverride); if (Optional.IsDefined(StepSize) || hasPropertyOverride) { - builder.Append(" stepSize:"); + builder.Append(" stepSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StepSize.Value}"); + builder.AppendLine($"{StepSize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Default), out propertyOverride); if (Optional.IsDefined(Default) || hasPropertyOverride) { - builder.Append(" default:"); + builder.Append(" default: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Default.Value}"); + builder.AppendLine($"{Default.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DoNotPauseValue), out propertyOverride); if (Optional.IsDefined(DoNotPauseValue) || hasPropertyOverride) { - builder.Append(" doNotPauseValue:"); + builder.Append(" doNotPauseValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DoNotPauseValue.Value}"); + builder.AppendLine($"{DoNotPauseValue.Value}"); } } @@ -268,12 +268,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -294,13 +297,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningOptions.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningOptions.Serialization.cs index 14e22c4b99684..45927803735d8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningOptions.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningOptions.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DesiredState), out propertyOverride); if (Optional.IsDefined(DesiredState) || hasPropertyOverride) { - builder.Append(" desiredState:"); + builder.Append(" desiredState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DesiredState.Value.ToSerialString()}'"); + builder.AppendLine($"'{DesiredState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActualState), out propertyOverride); if (Optional.IsDefined(ActualState) || hasPropertyOverride) { - builder.Append(" actualState:"); + builder.Append(" actualState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActualState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActualState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonCode), out propertyOverride); if (Optional.IsDefined(ReasonCode) || hasPropertyOverride) { - builder.Append(" reasonCode:"); + builder.Append(" reasonCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ReasonCode.Value}"); + builder.AppendLine($"{ReasonCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonDesc), out propertyOverride); if (Optional.IsDefined(ReasonDesc) || hasPropertyOverride) { - builder.Append(" reasonDesc:"); + builder.Append(" reasonDesc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReasonDesc.Value.ToSerialString()}'"); + builder.AppendLine($"'{ReasonDesc.Value.ToSerialString()}'"); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningServerOptions.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningServerOptions.Serialization.cs index 78a509e3896a7..3341294d39237 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningServerOptions.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AutomaticTuningServerOptions.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DesiredState), out propertyOverride); if (Optional.IsDefined(DesiredState) || hasPropertyOverride) { - builder.Append(" desiredState:"); + builder.Append(" desiredState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DesiredState.Value.ToSerialString()}'"); + builder.AppendLine($"'{DesiredState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActualState), out propertyOverride); if (Optional.IsDefined(ActualState) || hasPropertyOverride) { - builder.Append(" actualState:"); + builder.Append(" actualState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActualState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActualState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonCode), out propertyOverride); if (Optional.IsDefined(ReasonCode) || hasPropertyOverride) { - builder.Append(" reasonCode:"); + builder.Append(" reasonCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ReasonCode.Value}"); + builder.AppendLine($"{ReasonCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonDesc), out propertyOverride); if (Optional.IsDefined(ReasonDesc) || hasPropertyOverride) { - builder.Append(" reasonDesc:"); + builder.Append(" reasonDesc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReasonDesc.Value.ToSerialString()}'"); + builder.AppendLine($"'{ReasonDesc.Value.ToSerialString()}'"); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AzureADOnlyAuthListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AzureADOnlyAuthListResult.Serialization.cs index 2c98dd9421966..c8b8be1de9b63 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AzureADOnlyAuthListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AzureADOnlyAuthListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static AzureADOnlyAuthListResult DeserializeAzureADOnlyAuthListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerAzureADOnlyAuthenticationData.DeserializeSqlServerAzureADOnlyAuthenticationData(item, options)); + array.Add(SqlServerAzureADOnlyAuthenticationData.DeserializeSqlServerAzureADOnlyAuthenticationData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupShortTermRetentionPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupShortTermRetentionPolicyListResult.Serialization.cs index 681cb9248fa62..ef3764f978a22 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupShortTermRetentionPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupShortTermRetentionPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static BackupShortTermRetentionPolicyListResult DeserializeBackupShortT List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BackupShortTermRetentionPolicyData.DeserializeBackupShortTermRetentionPolicyData(item, options)); + array.Add(BackupShortTermRetentionPolicyData.DeserializeBackupShortTermRetentionPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRule.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRule.Serialization.cs index f07a222bdcd5a..0dd1e8fc5c45f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRule.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRule.Serialization.cs @@ -312,21 +312,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -334,35 +334,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -370,28 +370,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -400,21 +400,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AliasName), out propertyOverride); if (Optional.IsDefined(AliasName) || hasPropertyOverride) { - builder.Append(" aliasName:"); + builder.Append(" aliasName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AliasName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AliasName}'''"); } else { - builder.AppendLine($" '{AliasName}'"); + builder.AppendLine($"'{AliasName}'"); } } } @@ -422,35 +422,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleState), out propertyOverride); if (Optional.IsDefined(RuleState) || hasPropertyOverride) { - builder.Append(" ruleState:"); + builder.Append(" ruleState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RuleState.Value.ToSerialString()}'"); + builder.AppendLine($"'{RuleState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SchemaName), out propertyOverride); if (Optional.IsDefined(SchemaName) || hasPropertyOverride) { - builder.Append(" schemaName:"); + builder.Append(" schemaName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SchemaName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SchemaName}'''"); } else { - builder.AppendLine($" '{SchemaName}'"); + builder.AppendLine($"'{SchemaName}'"); } } } @@ -458,21 +458,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); if (Optional.IsDefined(TableName) || hasPropertyOverride) { - builder.Append(" tableName:"); + builder.Append(" tableName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TableName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TableName}'''"); } else { - builder.AppendLine($" '{TableName}'"); + builder.AppendLine($"'{TableName}'"); } } } @@ -480,21 +480,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnName), out propertyOverride); if (Optional.IsDefined(ColumnName) || hasPropertyOverride) { - builder.Append(" columnName:"); + builder.Append(" columnName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ColumnName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ColumnName}'''"); } else { - builder.AppendLine($" '{ColumnName}'"); + builder.AppendLine($"'{ColumnName}'"); } } } @@ -502,35 +502,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaskingFunction), out propertyOverride); if (Optional.IsDefined(MaskingFunction) || hasPropertyOverride) { - builder.Append(" maskingFunction:"); + builder.Append(" maskingFunction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaskingFunction.Value.ToSerialString()}'"); + builder.AppendLine($"'{MaskingFunction.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberFrom), out propertyOverride); if (Optional.IsDefined(NumberFrom) || hasPropertyOverride) { - builder.Append(" numberFrom:"); + builder.Append(" numberFrom: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NumberFrom.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NumberFrom}'''"); } else { - builder.AppendLine($" '{NumberFrom}'"); + builder.AppendLine($"'{NumberFrom}'"); } } } @@ -538,21 +538,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberTo), out propertyOverride); if (Optional.IsDefined(NumberTo) || hasPropertyOverride) { - builder.Append(" numberTo:"); + builder.Append(" numberTo: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NumberTo.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NumberTo}'''"); } else { - builder.AppendLine($" '{NumberTo}'"); + builder.AppendLine($"'{NumberTo}'"); } } } @@ -560,21 +560,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrefixSize), out propertyOverride); if (Optional.IsDefined(PrefixSize) || hasPropertyOverride) { - builder.Append(" prefixSize:"); + builder.Append(" prefixSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrefixSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrefixSize}'''"); } else { - builder.AppendLine($" '{PrefixSize}'"); + builder.AppendLine($"'{PrefixSize}'"); } } } @@ -582,21 +582,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuffixSize), out propertyOverride); if (Optional.IsDefined(SuffixSize) || hasPropertyOverride) { - builder.Append(" suffixSize:"); + builder.Append(" suffixSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SuffixSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SuffixSize}'''"); } else { - builder.AppendLine($" '{SuffixSize}'"); + builder.AppendLine($"'{SuffixSize}'"); } } } @@ -604,21 +604,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplacementString), out propertyOverride); if (Optional.IsDefined(ReplacementString) || hasPropertyOverride) { - builder.Append(" replacementString:"); + builder.Append(" replacementString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ReplacementString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ReplacementString}'''"); } else { - builder.AppendLine($" '{ReplacementString}'"); + builder.AppendLine($"'{ReplacementString}'"); } } } @@ -628,12 +628,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -654,13 +657,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRuleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRuleListResult.Serialization.cs index fe4c84fd2a072..978f7cf33e11e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRuleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataMaskingRuleListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static DataMaskingRuleListResult DeserializeDataMaskingRuleListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DataMaskingRule.DeserializeDataMaskingRule(item, options)); + array.Add(DataMaskingRule.DeserializeDataMaskingRule(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataWarehouseUserActivitiesListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataWarehouseUserActivitiesListResult.Serialization.cs index cd23b73d54903..497a67e39579e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataWarehouseUserActivitiesListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DataWarehouseUserActivitiesListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DataWarehouseUserActivitiesListResult DeserializeDataWarehouseUs List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DataWarehouseUserActivityData.DeserializeDataWarehouseUserActivityData(item, options)); + array.Add(DataWarehouseUserActivityData.DeserializeDataWarehouseUserActivityData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs index 28d88bb8db90c..77dde7f124a60 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseAdvancedThreatProtectionListResult DeserializeDatabaseAd List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(item, options)); + array.Add(DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseBlobAuditingPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseBlobAuditingPolicyListResult.Serialization.cs index 0a070b587c278..9140621c45394 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseBlobAuditingPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseBlobAuditingPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseBlobAuditingPolicyListResult DeserializeDatabaseBlobAudi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlDatabaseBlobAuditingPolicyData.DeserializeSqlDatabaseBlobAuditingPolicyData(item, options)); + array.Add(SqlDatabaseBlobAuditingPolicyData.DeserializeSqlDatabaseBlobAuditingPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseColumnListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseColumnListResult.Serialization.cs index 90cc05d673e78..5cd4aa3623c05 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseColumnListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseColumnListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseColumnListResult DeserializeDatabaseColumnListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseColumnData.DeserializeDatabaseColumnData(item, options)); + array.Add(DatabaseColumnData.DeserializeDatabaseColumnData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseExportDefinition.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseExportDefinition.Serialization.cs index e7adad4d1ff60..e4fdca9169e29 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseExportDefinition.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseExportDefinition.Serialization.cs @@ -131,7 +131,7 @@ internal static DatabaseExportDefinition DeserializeDatabaseExportDefinition(Jso { continue; } - networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value, options); + networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs index 01c2ad20b15df..35e5180bf4efd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs @@ -151,14 +151,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -167,18 +167,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserAssignedIdentities.Any() || hasPropertyOverride) { - builder.Append(" userAssignedIdentities:"); + builder.Append(" userAssignedIdentities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in UserAssignedIdentities) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " userAssignedIdentities: "); } builder.AppendLine(" }"); } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseImportDefinition.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseImportDefinition.Serialization.cs index da94d82417dbb..e73a0cc4e24cd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseImportDefinition.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseImportDefinition.Serialization.cs @@ -175,7 +175,7 @@ internal static DatabaseImportDefinition DeserializeDatabaseImportDefinition(Jso { continue; } - networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value, options); + networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseListResult.Serialization.cs index ebbc5265e29d3..9791d1b8466e5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseListResult DeserializeDatabaseListResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlDatabaseData.DeserializeSqlDatabaseData(item, options)); + array.Add(SqlDatabaseData.DeserializeSqlDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationData.Serialization.cs index 64a6ef9808c25..5345003ab3b7e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationData.Serialization.cs @@ -343,21 +343,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -365,28 +365,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -395,21 +395,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -417,21 +417,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -439,21 +439,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationFriendlyName), out propertyOverride); if (Optional.IsDefined(OperationFriendlyName) || hasPropertyOverride) { - builder.Append(" operationFriendlyName:"); + builder.Append(" operationFriendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationFriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationFriendlyName}'''"); } else { - builder.AppendLine($" '{OperationFriendlyName}'"); + builder.AppendLine($"'{OperationFriendlyName}'"); } } } @@ -461,35 +461,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -497,64 +497,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDescription), out propertyOverride); if (Optional.IsDefined(ErrorDescription) || hasPropertyOverride) { - builder.Append(" errorDescription:"); + builder.Append(" errorDescription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorDescription}'''"); } else { - builder.AppendLine($" '{ErrorDescription}'"); + builder.AppendLine($"'{ErrorDescription}'"); } } } @@ -562,65 +562,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUserError), out propertyOverride); if (Optional.IsDefined(IsUserError) || hasPropertyOverride) { - builder.Append(" isUserError:"); + builder.Append(" isUserError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUserError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EstimatedCompleteOn), out propertyOverride); if (Optional.IsDefined(EstimatedCompleteOn) || hasPropertyOverride) { - builder.Append(" estimatedCompletionTime:"); + builder.Append(" estimatedCompletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EstimatedCompleteOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -628,15 +628,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsCancellable), out propertyOverride); if (Optional.IsDefined(IsCancellable) || hasPropertyOverride) { - builder.Append(" isCancellable:"); + builder.Append(" isCancellable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsCancellable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -645,12 +645,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -671,13 +674,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationListResult.Serialization.cs index 7f4d61a011b70..c6dafeb04c0e5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseOperationListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static DatabaseOperationListResult DeserializeDatabaseOperationListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseOperationData.DeserializeDatabaseOperationData(item, options)); + array.Add(DatabaseOperationData.DeserializeDatabaseOperationData(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSchemaListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSchemaListResult.Serialization.cs index 1a113f70eb860..1dd28a76620f1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSchemaListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSchemaListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseSchemaListResult DeserializeDatabaseSchemaListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseSchemaData.DeserializeDatabaseSchemaData(item, options)); + array.Add(DatabaseSchemaData.DeserializeDatabaseSchemaData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSecurityAlertListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSecurityAlertListResult.Serialization.cs index 5a8a75521aee4..2e0881f27f194 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSecurityAlertListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSecurityAlertListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseSecurityAlertListResult DeserializeDatabaseSecurityAlert List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlDatabaseSecurityAlertPolicyData.DeserializeSqlDatabaseSecurityAlertPolicyData(item, options)); + array.Add(SqlDatabaseSecurityAlertPolicyData.DeserializeSqlDatabaseSecurityAlertPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentBaselineSetListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentBaselineSetListResult.Serialization.cs index 9d339e2a0bd2b..081b2c073e9f3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentBaselineSetListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentBaselineSetListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseSqlVulnerabilityAssessmentBaselineSetListResult Deserial List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentBaselineData.DeserializeSqlVulnerabilityAssessmentBaselineData(item, options)); + array.Add(SqlVulnerabilityAssessmentBaselineData.DeserializeSqlVulnerabilityAssessmentBaselineData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult.Serialization.cs index 0abf3dc9e4874..de05e6c4e519b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult Deseria List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentBaselineRuleData.DeserializeSqlVulnerabilityAssessmentBaselineRuleData(item, options)); + array.Add(SqlVulnerabilityAssessmentBaselineRuleData.DeserializeSqlVulnerabilityAssessmentBaselineRuleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseTableListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseTableListResult.Serialization.cs index 917b467d3b29d..9a6a19d9972cb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseTableListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseTableListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseTableListResult DeserializeDatabaseTableListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseTableData.DeserializeDatabaseTableData(item, options)); + array.Add(DatabaseTableData.DeserializeDatabaseTableData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsage.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsage.Serialization.cs index 663d9523dc0f0..29f6333f8131b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsage.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsage.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,28 +231,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -261,21 +261,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -283,49 +283,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.Value.ToString()}'"); + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsageListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsageListResult.Serialization.cs index f70cece16b553..07f2c8ba5820f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsageListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUsageListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static DatabaseUsageListResult DeserializeDatabaseUsageListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseUsage.DeserializeDatabaseUsage(item, options)); + array.Add(DatabaseUsage.DeserializeDatabaseUsage(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentListResult.Serialization.cs index e86d5627a61ac..727e7112a5d30 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DatabaseVulnerabilityAssessmentListResult DeserializeDatabaseVul List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DatabaseVulnerabilityAssessmentData.DeserializeDatabaseVulnerabilityAssessmentData(item, options)); + array.Add(DatabaseVulnerabilityAssessmentData.DeserializeDatabaseVulnerabilityAssessmentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentRuleBaselineItem.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentRuleBaselineItem.Serialization.cs index c924cd3c81dec..4a241dffce665 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentRuleBaselineItem.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentRuleBaselineItem.Serialization.cs @@ -114,14 +114,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Result.Any() || hasPropertyOverride) { - builder.Append(" result:"); + builder.Append(" result: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Result) { if (item == null) @@ -148,12 +148,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -174,13 +177,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentScansExport.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentScansExport.Serialization.cs index 62b8f2ffbaa19..9fe1b7ebc2be4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentScansExport.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseVulnerabilityAssessmentScansExport.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExportedReportLocation), out propertyOverride); if (Optional.IsDefined(ExportedReportLocation) || hasPropertyOverride) { - builder.Append(" exportedReportLocation:"); + builder.Append(" exportedReportLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ExportedReportLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ExportedReportLocation}'''"); } else { - builder.AppendLine($" '{ExportedReportLocation}'"); + builder.AppendLine($"'{ExportedReportLocation}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DeletedServerListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DeletedServerListResult.Serialization.cs index a616deb7f1ec1..ae502449d8955 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DeletedServerListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DeletedServerListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DeletedServerListResult DeserializeDeletedServerListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeletedServerData.DeserializeDeletedServerData(item, options)); + array.Add(DeletedServerData.DeserializeDeletedServerData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs index 044e226f654cb..73fcc458f8999 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DistributedAvailabilityGroupsListResult DeserializeDistributedAv List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(item, options)); + array.Add(DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EditionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EditionCapability.Serialization.cs index 725b6a3bead00..a57153f423bf7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EditionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EditionCapability.Serialization.cs @@ -137,7 +137,7 @@ internal static EditionCapability DeserializeEditionCapability(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ServiceObjectiveCapability.DeserializeServiceObjectiveCapability(item, options)); + array.Add(ServiceObjectiveCapability.DeserializeServiceObjectiveCapability(item)); } supportedServiceLevelObjectives = array; continue; @@ -157,7 +157,7 @@ internal static EditionCapability DeserializeEditionCapability(JsonElement eleme { continue; } - readScale = ReadScaleCapability.DeserializeReadScaleCapability(property.Value, options); + readScale = ReadScaleCapability.DeserializeReadScaleCapability(property.Value); continue; } if (property.NameEquals("supportedStorageCapabilities"u8)) @@ -169,7 +169,7 @@ internal static EditionCapability DeserializeEditionCapability(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageCapability.DeserializeStorageCapability(item, options)); + array.Add(StorageCapability.DeserializeStorageCapability(item)); } supportedStorageCapabilities = array; continue; @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -235,17 +235,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedServiceLevelObjectives.Any() || hasPropertyOverride) { - builder.Append(" supportedServiceLevelObjectives:"); + builder.Append(" supportedServiceLevelObjectives: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedServiceLevelObjectives) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedServiceLevelObjectives: "); } builder.AppendLine(" ]"); } @@ -255,29 +255,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadScale), out propertyOverride); if (Optional.IsDefined(ReadScale) || hasPropertyOverride) { - builder.Append(" readScale:"); + builder.Append(" readScale: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ReadScale, options, 2, false); + AppendChildObject(builder, ReadScale, options, 2, false, " readScale: "); } } @@ -286,17 +286,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedStorageCapabilities.Any() || hasPropertyOverride) { - builder.Append(" supportedStorageCapabilities:"); + builder.Append(" supportedStorageCapabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedStorageCapabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedStorageCapabilities: "); } builder.AppendLine(" ]"); } @@ -306,35 +306,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -343,12 +343,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -369,13 +372,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivity.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivity.Serialization.cs index bb48a3eca87e3..8187a4ab12255 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivity.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivity.Serialization.cs @@ -448,21 +448,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -470,42 +470,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -514,50 +514,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -565,35 +565,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -601,91 +601,91 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationId), out propertyOverride); if (Optional.IsDefined(OperationId) || hasPropertyOverride) { - builder.Append(" operationId:"); + builder.Append(" operationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OperationId.Value.ToString()}'"); + builder.AppendLine($"'{OperationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDatabaseDtuMax), out propertyOverride); if (Optional.IsDefined(RequestedDatabaseDtuMax) || hasPropertyOverride) { - builder.Append(" requestedDatabaseDtuMax:"); + builder.Append(" requestedDatabaseDtuMax: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDatabaseDtuMax.Value}"); + builder.AppendLine($"{RequestedDatabaseDtuMax.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDatabaseDtuMin), out propertyOverride); if (Optional.IsDefined(RequestedDatabaseDtuMin) || hasPropertyOverride) { - builder.Append(" requestedDatabaseDtuMin:"); + builder.Append(" requestedDatabaseDtuMin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDatabaseDtuMin.Value}"); + builder.AppendLine($"{RequestedDatabaseDtuMin.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDtu), out propertyOverride); if (Optional.IsDefined(RequestedDtu) || hasPropertyOverride) { - builder.Append(" requestedDtu:"); + builder.Append(" requestedDtu: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDtu.Value}"); + builder.AppendLine($"{RequestedDtu.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedElasticPoolName), out propertyOverride); if (Optional.IsDefined(RequestedElasticPoolName) || hasPropertyOverride) { - builder.Append(" requestedElasticPoolName:"); + builder.Append(" requestedElasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestedElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestedElasticPoolName}'''"); } else { - builder.AppendLine($" '{RequestedElasticPoolName}'"); + builder.AppendLine($"'{RequestedElasticPoolName}'"); } } } @@ -693,35 +693,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedStorageLimitInGB), out propertyOverride); if (Optional.IsDefined(RequestedStorageLimitInGB) || hasPropertyOverride) { - builder.Append(" requestedStorageLimitInGB:"); + builder.Append(" requestedStorageLimitInGB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestedStorageLimitInGB.Value.ToString()}'"); + builder.AppendLine($"'{RequestedStorageLimitInGB.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticPoolName), out propertyOverride); if (Optional.IsDefined(ElasticPoolName) || hasPropertyOverride) { - builder.Append(" elasticPoolName:"); + builder.Append(" elasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ElasticPoolName}'''"); } else { - builder.AppendLine($" '{ElasticPoolName}'"); + builder.AppendLine($"'{ElasticPoolName}'"); } } } @@ -729,21 +729,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -751,36 +751,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -788,56 +788,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedStorageLimitInMB), out propertyOverride); if (Optional.IsDefined(RequestedStorageLimitInMB) || hasPropertyOverride) { - builder.Append(" requestedStorageLimitInMB:"); + builder.Append(" requestedStorageLimitInMB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedStorageLimitInMB.Value}"); + builder.AppendLine($"{RequestedStorageLimitInMB.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDatabaseDtuGuarantee), out propertyOverride); if (Optional.IsDefined(RequestedDatabaseDtuGuarantee) || hasPropertyOverride) { - builder.Append(" requestedDatabaseDtuGuarantee:"); + builder.Append(" requestedDatabaseDtuGuarantee: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDatabaseDtuGuarantee.Value}"); + builder.AppendLine($"{RequestedDatabaseDtuGuarantee.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDatabaseDtuCap), out propertyOverride); if (Optional.IsDefined(RequestedDatabaseDtuCap) || hasPropertyOverride) { - builder.Append(" requestedDatabaseDtuCap:"); + builder.Append(" requestedDatabaseDtuCap: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDatabaseDtuCap.Value}"); + builder.AppendLine($"{RequestedDatabaseDtuCap.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedDtuGuarantee), out propertyOverride); if (Optional.IsDefined(RequestedDtuGuarantee) || hasPropertyOverride) { - builder.Append(" requestedDtuGuarantee:"); + builder.Append(" requestedDtuGuarantee: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedDtuGuarantee.Value}"); + builder.AppendLine($"{RequestedDtuGuarantee.Value}"); } } @@ -846,12 +846,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -872,13 +875,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivityListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivityListResult.Serialization.cs index 63bf7417d2569..5b42a1c523fbc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivityListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolActivityListResult.Serialization.cs @@ -84,7 +84,7 @@ internal static ElasticPoolActivityListResult DeserializeElasticPoolActivityList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolActivity.DeserializeElasticPoolActivity(item, options)); + array.Add(ElasticPoolActivity.DeserializeElasticPoolActivity(item)); } value = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivity.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivity.Serialization.cs index 99dbd416a5fc6..0580522452298 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivity.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivity.Serialization.cs @@ -361,21 +361,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -383,42 +383,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -427,21 +427,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -449,50 +449,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -500,35 +500,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -536,49 +536,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationId), out propertyOverride); if (Optional.IsDefined(OperationId) || hasPropertyOverride) { - builder.Append(" operationId:"); + builder.Append(" operationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OperationId.Value.ToString()}'"); + builder.AppendLine($"'{OperationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedElasticPoolName), out propertyOverride); if (Optional.IsDefined(RequestedElasticPoolName) || hasPropertyOverride) { - builder.Append(" requestedElasticPoolName:"); + builder.Append(" requestedElasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestedElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestedElasticPoolName}'''"); } else { - builder.AppendLine($" '{RequestedElasticPoolName}'"); + builder.AppendLine($"'{RequestedElasticPoolName}'"); } } } @@ -586,21 +586,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentElasticPoolName), out propertyOverride); if (Optional.IsDefined(CurrentElasticPoolName) || hasPropertyOverride) { - builder.Append(" currentElasticPoolName:"); + builder.Append(" currentElasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentElasticPoolName}'''"); } else { - builder.AppendLine($" '{CurrentElasticPoolName}'"); + builder.AppendLine($"'{CurrentElasticPoolName}'"); } } } @@ -608,21 +608,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentServiceObjective), out propertyOverride); if (Optional.IsDefined(CurrentServiceObjective) || hasPropertyOverride) { - builder.Append(" currentServiceObjective:"); + builder.Append(" currentServiceObjective: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentServiceObjective.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentServiceObjective}'''"); } else { - builder.AppendLine($" '{CurrentServiceObjective}'"); + builder.AppendLine($"'{CurrentServiceObjective}'"); } } } @@ -630,21 +630,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedServiceObjective), out propertyOverride); if (Optional.IsDefined(RequestedServiceObjective) || hasPropertyOverride) { - builder.Append(" requestedServiceObjective:"); + builder.Append(" requestedServiceObjective: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestedServiceObjective.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestedServiceObjective}'''"); } else { - builder.AppendLine($" '{RequestedServiceObjective}'"); + builder.AppendLine($"'{RequestedServiceObjective}'"); } } } @@ -652,21 +652,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -674,36 +674,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -713,12 +713,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -739,13 +742,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivityListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivityListResult.Serialization.cs index a9114cc46be5d..aeda75df2d0c3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivityListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolDatabaseActivityListResult.Serialization.cs @@ -84,7 +84,7 @@ internal static ElasticPoolDatabaseActivityListResult DeserializeElasticPoolData List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolDatabaseActivity.DeserializeElasticPoolDatabaseActivity(item, options)); + array.Add(ElasticPoolDatabaseActivity.DeserializeElasticPoolDatabaseActivity(item)); } value = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolEditionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolEditionCapability.Serialization.cs index 2c4faad03de04..6805087210aad 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolEditionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolEditionCapability.Serialization.cs @@ -120,7 +120,7 @@ internal static ElasticPoolEditionCapability DeserializeElasticPoolEditionCapabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolPerformanceLevelCapability.DeserializeElasticPoolPerformanceLevelCapability(item, options)); + array.Add(ElasticPoolPerformanceLevelCapability.DeserializeElasticPoolPerformanceLevelCapability(item)); } supportedElasticPoolPerformanceLevels = array; continue; @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,17 +195,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedElasticPoolPerformanceLevels.Any() || hasPropertyOverride) { - builder.Append(" supportedElasticPoolPerformanceLevels:"); + builder.Append(" supportedElasticPoolPerformanceLevels: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedElasticPoolPerformanceLevels) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedElasticPoolPerformanceLevels: "); } builder.AppendLine(" ]"); } @@ -215,50 +215,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -267,12 +267,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -293,13 +296,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolListResult.Serialization.cs index 1a660341c4eae..3ca2f9ac1897a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ElasticPoolListResult DeserializeElasticPoolListResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolData.DeserializeElasticPoolData(item, options)); + array.Add(ElasticPoolData.DeserializeElasticPoolData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationData.Serialization.cs index 4604fb2ec905c..6de8547e64ba7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationData.Serialization.cs @@ -339,21 +339,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -361,28 +361,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -391,21 +391,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticPoolName), out propertyOverride); if (Optional.IsDefined(ElasticPoolName) || hasPropertyOverride) { - builder.Append(" elasticPoolName:"); + builder.Append(" elasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ElasticPoolName}'''"); } else { - builder.AppendLine($" '{ElasticPoolName}'"); + builder.AppendLine($"'{ElasticPoolName}'"); } } } @@ -413,21 +413,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -435,21 +435,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationFriendlyName), out propertyOverride); if (Optional.IsDefined(OperationFriendlyName) || hasPropertyOverride) { - builder.Append(" operationFriendlyName:"); + builder.Append(" operationFriendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationFriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationFriendlyName}'''"); } else { - builder.AppendLine($" '{OperationFriendlyName}'"); + builder.AppendLine($"'{OperationFriendlyName}'"); } } } @@ -457,35 +457,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -493,36 +493,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -530,35 +530,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDescription), out propertyOverride); if (Optional.IsDefined(ErrorDescription) || hasPropertyOverride) { - builder.Append(" errorDescription:"); + builder.Append(" errorDescription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorDescription}'''"); } else { - builder.AppendLine($" '{ErrorDescription}'"); + builder.AppendLine($"'{ErrorDescription}'"); } } } @@ -566,65 +566,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUserError), out propertyOverride); if (Optional.IsDefined(IsUserError) || hasPropertyOverride) { - builder.Append(" isUserError:"); + builder.Append(" isUserError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUserError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EstimatedCompleteOn), out propertyOverride); if (Optional.IsDefined(EstimatedCompleteOn) || hasPropertyOverride) { - builder.Append(" estimatedCompletionTime:"); + builder.Append(" estimatedCompletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EstimatedCompleteOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -632,15 +632,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsCancellable), out propertyOverride); if (Optional.IsDefined(IsCancellable) || hasPropertyOverride) { - builder.Append(" isCancellable:"); + builder.Append(" isCancellable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsCancellable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -649,12 +649,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -675,13 +678,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationListResult.Serialization.cs index ead0750b2c31b..288abb6691210 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolOperationListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ElasticPoolOperationListResult DeserializeElasticPoolOperationLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolOperationData.DeserializeElasticPoolOperationData(item, options)); + array.Add(ElasticPoolOperationData.DeserializeElasticPoolOperationData(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPatch.Serialization.cs index 3410e7e04cc2c..89e5c8cbc9b30 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPatch.Serialization.cs @@ -149,7 +149,7 @@ internal static ElasticPoolPatch DeserializeElasticPoolPatch(JsonElement element { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -199,7 +199,7 @@ internal static ElasticPoolPatch DeserializeElasticPoolPatch(JsonElement element { continue; } - perDatabaseSettings = ElasticPoolPerDatabaseSettings.DeserializeElasticPoolPerDatabaseSettings(property0.Value, options); + perDatabaseSettings = ElasticPoolPerDatabaseSettings.DeserializeElasticPoolPerDatabaseSettings(property0.Value); continue; } if (property0.NameEquals("zoneRedundant"u8)) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMaxPerformanceLevelCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMaxPerformanceLevelCapability.Serialization.cs index 957e60c63d149..7ee46efcf58d1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMaxPerformanceLevelCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMaxPerformanceLevelCapability.Serialization.cs @@ -133,7 +133,7 @@ internal static ElasticPoolPerDatabaseMaxPerformanceLevelCapability DeserializeE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolPerDatabaseMinPerformanceLevelCapability.DeserializeElasticPoolPerDatabaseMinPerformanceLevelCapability(item, options)); + array.Add(ElasticPoolPerDatabaseMinPerformanceLevelCapability.DeserializeElasticPoolPerDatabaseMinPerformanceLevelCapability(item)); } supportedPerDatabaseMinPerformanceLevels = array; continue; @@ -175,28 +175,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -205,17 +205,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedPerDatabaseMinPerformanceLevels.Any() || hasPropertyOverride) { - builder.Append(" supportedPerDatabaseMinPerformanceLevels:"); + builder.Append(" supportedPerDatabaseMinPerformanceLevels: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedPerDatabaseMinPerformanceLevels) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedPerDatabaseMinPerformanceLevels: "); } builder.AppendLine(" ]"); } @@ -225,35 +225,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -262,12 +262,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -288,13 +291,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMinPerformanceLevelCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMinPerformanceLevelCapability.Serialization.cs index 9d7172b788566..97e26a7f92af5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMinPerformanceLevelCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseMinPerformanceLevelCapability.Serialization.cs @@ -149,63 +149,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -214,12 +214,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -240,13 +243,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseSettings.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseSettings.Serialization.cs index 57844b4ae5390..b3e6a1cbb9318 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseSettings.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerDatabaseSettings.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCapacity), out propertyOverride); if (Optional.IsDefined(MinCapacity) || hasPropertyOverride) { - builder.Append(" minCapacity:"); + builder.Append(" minCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinCapacity.Value.ToString()}'"); + builder.AppendLine($"'{MinCapacity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxCapacity), out propertyOverride); if (Optional.IsDefined(MaxCapacity) || hasPropertyOverride) { - builder.Append(" maxCapacity:"); + builder.Append(" maxCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxCapacity.Value.ToString()}'"); + builder.AppendLine($"'{MaxCapacity.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerformanceLevelCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerformanceLevelCapability.Serialization.cs index e837cabed7f28..9d5bd41b8b036 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerformanceLevelCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ElasticPoolPerformanceLevelCapability.Serialization.cs @@ -174,7 +174,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf { continue; } - performanceLevel = PerformanceLevelCapability.DeserializePerformanceLevelCapability(property.Value, options); + performanceLevel = PerformanceLevelCapability.DeserializePerformanceLevelCapability(property.Value); continue; } if (property.NameEquals("sku"u8)) @@ -183,7 +183,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("supportedLicenseTypes"u8)) @@ -195,7 +195,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item, options)); + array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item)); } supportedLicenseTypes = array; continue; @@ -215,7 +215,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf { continue; } - includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("supportedMaxSizes"u8)) @@ -227,7 +227,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item, options)); + array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item)); } supportedMaxSizes = array; continue; @@ -241,7 +241,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item, options)); + array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item)); } supportedPerDatabaseMaxSizes = array; continue; @@ -255,7 +255,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolPerDatabaseMaxPerformanceLevelCapability.DeserializeElasticPoolPerDatabaseMaxPerformanceLevelCapability(item, options)); + array.Add(ElasticPoolPerDatabaseMaxPerformanceLevelCapability.DeserializeElasticPoolPerDatabaseMaxPerformanceLevelCapability(item)); } supportedPerDatabaseMaxPerformanceLevels = array; continue; @@ -278,7 +278,7 @@ internal static ElasticPoolPerformanceLevelCapability DeserializeElasticPoolPerf List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaintenanceConfigurationCapability.DeserializeMaintenanceConfigurationCapability(item, options)); + array.Add(MaintenanceConfigurationCapability.DeserializeMaintenanceConfigurationCapability(item)); } supportedMaintenanceConfigurations = array; continue; @@ -320,28 +320,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PerformanceLevel), out propertyOverride); if (Optional.IsDefined(PerformanceLevel) || hasPropertyOverride) { - builder.Append(" performanceLevel:"); + builder.Append(" performanceLevel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PerformanceLevel, options, 2, false); + AppendChildObject(builder, PerformanceLevel, options, 2, false, " performanceLevel: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } @@ -350,17 +350,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedLicenseTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedLicenseTypes:"); + builder.Append(" supportedLicenseTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedLicenseTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedLicenseTypes: "); } builder.AppendLine(" ]"); } @@ -370,28 +370,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxDatabaseCount), out propertyOverride); if (Optional.IsDefined(MaxDatabaseCount) || hasPropertyOverride) { - builder.Append(" maxDatabaseCount:"); + builder.Append(" maxDatabaseCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxDatabaseCount.Value}"); + builder.AppendLine($"{MaxDatabaseCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludedMaxSize), out propertyOverride); if (Optional.IsDefined(IncludedMaxSize) || hasPropertyOverride) { - builder.Append(" includedMaxSize:"); + builder.Append(" includedMaxSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IncludedMaxSize, options, 2, false); + AppendChildObject(builder, IncludedMaxSize, options, 2, false, " includedMaxSize: "); } } @@ -400,17 +400,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMaxSizes.Any() || hasPropertyOverride) { - builder.Append(" supportedMaxSizes:"); + builder.Append(" supportedMaxSizes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMaxSizes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMaxSizes: "); } builder.AppendLine(" ]"); } @@ -422,17 +422,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedPerDatabaseMaxSizes.Any() || hasPropertyOverride) { - builder.Append(" supportedPerDatabaseMaxSizes:"); + builder.Append(" supportedPerDatabaseMaxSizes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedPerDatabaseMaxSizes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedPerDatabaseMaxSizes: "); } builder.AppendLine(" ]"); } @@ -444,17 +444,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedPerDatabaseMaxPerformanceLevels.Any() || hasPropertyOverride) { - builder.Append(" supportedPerDatabaseMaxPerformanceLevels:"); + builder.Append(" supportedPerDatabaseMaxPerformanceLevels: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedPerDatabaseMaxPerformanceLevels) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedPerDatabaseMaxPerformanceLevels: "); } builder.AppendLine(" ]"); } @@ -464,15 +464,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -481,17 +481,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMaintenanceConfigurations.Any() || hasPropertyOverride) { - builder.Append(" supportedMaintenanceConfigurations:"); + builder.Append(" supportedMaintenanceConfigurations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMaintenanceConfigurations) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMaintenanceConfigurations: "); } builder.AppendLine(" ]"); } @@ -501,35 +501,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -538,12 +538,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -564,13 +567,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EncryptionProtectorListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EncryptionProtectorListResult.Serialization.cs index ffe98dcddfb30..16c0c212545c7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EncryptionProtectorListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EncryptionProtectorListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static EncryptionProtectorListResult DeserializeEncryptionProtectorList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(EncryptionProtectorData.DeserializeEncryptionProtectorData(item, options)); + array.Add(EncryptionProtectorData.DeserializeEncryptionProtectorData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EndpointCertificateListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EndpointCertificateListResult.Serialization.cs index 12cc298a32bc5..058b4b8d83136 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EndpointCertificateListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/EndpointCertificateListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static EndpointCertificateListResult DeserializeEndpointCertificateList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(EndpointCertificateData.DeserializeEndpointCertificateData(item, options)); + array.Add(EndpointCertificateData.DeserializeEndpointCertificateData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedDatabaseBlobAuditingPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedDatabaseBlobAuditingPolicyListResult.Serialization.cs index ff4a5fa27a110..8ebf3575e33a8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedDatabaseBlobAuditingPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedDatabaseBlobAuditingPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ExtendedDatabaseBlobAuditingPolicyListResult DeserializeExtended List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ExtendedDatabaseBlobAuditingPolicyData.DeserializeExtendedDatabaseBlobAuditingPolicyData(item, options)); + array.Add(ExtendedDatabaseBlobAuditingPolicyData.DeserializeExtendedDatabaseBlobAuditingPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedServerBlobAuditingPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedServerBlobAuditingPolicyListResult.Serialization.cs index d7280c42467ed..6f9d2110e19df 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedServerBlobAuditingPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ExtendedServerBlobAuditingPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ExtendedServerBlobAuditingPolicyListResult DeserializeExtendedSe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ExtendedServerBlobAuditingPolicyData.DeserializeExtendedServerBlobAuditingPolicyData(item, options)); + array.Add(ExtendedServerBlobAuditingPolicyData.DeserializeExtendedServerBlobAuditingPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupListResult.Serialization.cs index 3832d818f9922..3699945ef1b16 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static FailoverGroupListResult DeserializeFailoverGroupListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FailoverGroupData.DeserializeFailoverGroupData(item, options)); + array.Add(FailoverGroupData.DeserializeFailoverGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupPatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupPatch.Serialization.cs index 7cf636b3056fb..cb5014ebe04bd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupPatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupPatch.Serialization.cs @@ -151,7 +151,7 @@ internal static FailoverGroupPatch DeserializeFailoverGroupPatch(JsonElement ele { continue; } - readWriteEndpoint = FailoverGroupReadWriteEndpoint.DeserializeFailoverGroupReadWriteEndpoint(property0.Value, options); + readWriteEndpoint = FailoverGroupReadWriteEndpoint.DeserializeFailoverGroupReadWriteEndpoint(property0.Value); continue; } if (property0.NameEquals("readOnlyEndpoint"u8)) @@ -160,7 +160,7 @@ internal static FailoverGroupPatch DeserializeFailoverGroupPatch(JsonElement ele { continue; } - readOnlyEndpoint = FailoverGroupReadOnlyEndpoint.DeserializeFailoverGroupReadOnlyEndpoint(property0.Value, options); + readOnlyEndpoint = FailoverGroupReadOnlyEndpoint.DeserializeFailoverGroupReadOnlyEndpoint(property0.Value); continue; } if (property0.NameEquals("databases"u8)) @@ -193,7 +193,7 @@ internal static FailoverGroupPatch DeserializeFailoverGroupPatch(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PartnerServerInfo.DeserializePartnerServerInfo(item, options)); + array.Add(PartnerServerInfo.DeserializePartnerServerInfo(item)); } partnerServers = array; continue; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadOnlyEndpoint.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadOnlyEndpoint.Serialization.cs index 18fb92df75050..316bf56c06474 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadOnlyEndpoint.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadOnlyEndpoint.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverPolicy), out propertyOverride); if (Optional.IsDefined(FailoverPolicy) || hasPropertyOverride) { - builder.Append(" failoverPolicy:"); + builder.Append(" failoverPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverPolicy.Value.ToString()}'"); + builder.AppendLine($"'{FailoverPolicy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetServer), out propertyOverride); if (Optional.IsDefined(TargetServer) || hasPropertyOverride) { - builder.Append(" targetServer:"); + builder.Append(" targetServer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetServer.ToString()}'"); + builder.AppendLine($"'{TargetServer.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadWriteEndpoint.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadWriteEndpoint.Serialization.cs index b3cf4961f26da..fab68deba8d76 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadWriteEndpoint.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FailoverGroupReadWriteEndpoint.Serialization.cs @@ -116,28 +116,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverPolicy), out propertyOverride); if (Optional.IsDefined(FailoverPolicy) || hasPropertyOverride) { - builder.Append(" failoverPolicy:"); + builder.Append(" failoverPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverPolicy.ToString()}'"); + builder.AppendLine($"'{FailoverPolicy.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverWithDataLossGracePeriodMinutes), out propertyOverride); if (Optional.IsDefined(FailoverWithDataLossGracePeriodMinutes) || hasPropertyOverride) { - builder.Append(" failoverWithDataLossGracePeriodMinutes:"); + builder.Append(" failoverWithDataLossGracePeriodMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FailoverWithDataLossGracePeriodMinutes.Value}"); + builder.AppendLine($"{FailoverWithDataLossGracePeriodMinutes.Value}"); } } @@ -145,12 +145,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -171,13 +174,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FirewallRuleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FirewallRuleListResult.Serialization.cs index e2d9696861b59..263d252305f36 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FirewallRuleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/FirewallRuleListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static FirewallRuleListResult DeserializeFirewallRuleListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlFirewallRuleData.DeserializeSqlFirewallRuleData(item, options)); + array.Add(SqlFirewallRuleData.DeserializeSqlFirewallRuleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/GeoBackupPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/GeoBackupPolicyListResult.Serialization.cs index b147ed68babd5..b227e03503737 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/GeoBackupPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/GeoBackupPolicyListResult.Serialization.cs @@ -92,7 +92,7 @@ internal static GeoBackupPolicyListResult DeserializeGeoBackupPolicyListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(GeoBackupPolicyData.DeserializeGeoBackupPolicyData(item, options)); + array.Add(GeoBackupPolicyData.DeserializeGeoBackupPolicyData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/IPv6FirewallRuleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/IPv6FirewallRuleListResult.Serialization.cs index 5e2ebb8345c99..fca0600097d20 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/IPv6FirewallRuleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/IPv6FirewallRuleListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static IPv6FirewallRuleListResult DeserializeIPv6FirewallRuleListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(IPv6FirewallRuleData.DeserializeIPv6FirewallRuleData(item, options)); + array.Add(IPv6FirewallRuleData.DeserializeIPv6FirewallRuleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExistingDatabaseDefinition.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExistingDatabaseDefinition.Serialization.cs index 55366dec2d802..12495a86dd858 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExistingDatabaseDefinition.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExistingDatabaseDefinition.Serialization.cs @@ -131,7 +131,7 @@ internal static ImportExistingDatabaseDefinition DeserializeImportExistingDataba { continue; } - networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value, options); + networkIsolation = NetworkIsolationSettings.DeserializeNetworkIsolationSettings(property.Value); continue; } if (options.Format != "W") diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationListResult.Serialization.cs index 638cf0da125f8..e8bef4f92fb2a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ImportExportExtensionsOperationListResult DeserializeImportExpor List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ImportExportExtensionsOperationResult.DeserializeImportExportExtensionsOperationResult(item, options)); + array.Add(ImportExportExtensionsOperationResult.DeserializeImportExportExtensionsOperationResult(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationResult.Serialization.cs index 91f7cbf204b47..a31051505d650 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportExtensionsOperationResult.Serialization.cs @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -260,28 +260,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -290,35 +290,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestId), out propertyOverride); if (Optional.IsDefined(RequestId) || hasPropertyOverride) { - builder.Append(" requestId:"); + builder.Append(" requestId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestId.Value.ToString()}'"); + builder.AppendLine($"'{RequestId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestType), out propertyOverride); if (Optional.IsDefined(RequestType) || hasPropertyOverride) { - builder.Append(" requestType:"); + builder.Append(" requestType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestType}'''"); } else { - builder.AppendLine($" '{RequestType}'"); + builder.AppendLine($"'{RequestType}'"); } } } @@ -326,21 +326,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedTime), out propertyOverride); if (Optional.IsDefined(LastModifiedTime) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastModifiedTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastModifiedTime}'''"); } else { - builder.AppendLine($" '{LastModifiedTime}'"); + builder.AppendLine($"'{LastModifiedTime}'"); } } } @@ -348,21 +348,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -370,21 +370,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -392,21 +392,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -414,21 +414,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -438,12 +438,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -464,13 +467,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportOperationResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportOperationResult.Serialization.cs index 4e5b7385e8d1c..60d626fe7b596 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportOperationResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ImportExportOperationResult.Serialization.cs @@ -259,7 +259,7 @@ internal static ImportExportOperationResult DeserializeImportExportOperationResu List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(PrivateEndpointConnectionRequestStatus.DeserializePrivateEndpointConnectionRequestStatus(item, options)); + array.Add(PrivateEndpointConnectionRequestStatus.DeserializePrivateEndpointConnectionRequestStatus(item)); } privateEndpointConnections = array; continue; @@ -290,21 +290,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -312,28 +312,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -342,35 +342,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestId), out propertyOverride); if (Optional.IsDefined(RequestId) || hasPropertyOverride) { - builder.Append(" requestId:"); + builder.Append(" requestId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestId.Value.ToString()}'"); + builder.AppendLine($"'{RequestId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestType), out propertyOverride); if (Optional.IsDefined(RequestType) || hasPropertyOverride) { - builder.Append(" requestType:"); + builder.Append(" requestType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestType}'''"); } else { - builder.AppendLine($" '{RequestType}'"); + builder.AppendLine($"'{RequestType}'"); } } } @@ -378,21 +378,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueuedTime), out propertyOverride); if (Optional.IsDefined(QueuedTime) || hasPropertyOverride) { - builder.Append(" queuedTime:"); + builder.Append(" queuedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueuedTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueuedTime}'''"); } else { - builder.AppendLine($" '{QueuedTime}'"); + builder.AppendLine($"'{QueuedTime}'"); } } } @@ -400,21 +400,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedTime), out propertyOverride); if (Optional.IsDefined(LastModifiedTime) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastModifiedTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastModifiedTime}'''"); } else { - builder.AppendLine($" '{LastModifiedTime}'"); + builder.AppendLine($"'{LastModifiedTime}'"); } } } @@ -422,35 +422,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobUri), out propertyOverride); if (Optional.IsDefined(BlobUri) || hasPropertyOverride) { - builder.Append(" blobUri:"); + builder.Append(" blobUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BlobUri.AbsoluteUri}'"); + builder.AppendLine($"'{BlobUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -458,21 +458,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -480,21 +480,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -502,21 +502,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -526,17 +526,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -548,12 +548,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -574,13 +577,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupListResult.Serialization.cs index 2d8e1249bcedb..a21b4a71170b4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static InstanceFailoverGroupListResult DeserializeInstanceFailoverGroup List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstanceFailoverGroupData.DeserializeInstanceFailoverGroupData(item, options)); + array.Add(InstanceFailoverGroupData.DeserializeInstanceFailoverGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadOnlyEndpoint.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadOnlyEndpoint.Serialization.cs index c28489fa49318..eb1af70c7c3e7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadOnlyEndpoint.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadOnlyEndpoint.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverPolicy), out propertyOverride); if (Optional.IsDefined(FailoverPolicy) || hasPropertyOverride) { - builder.Append(" failoverPolicy:"); + builder.Append(" failoverPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverPolicy.Value.ToString()}'"); + builder.AppendLine($"'{FailoverPolicy.Value.ToString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadWriteEndpoint.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadWriteEndpoint.Serialization.cs index 49f30c6a1c85f..68237d473d86e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadWriteEndpoint.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstanceFailoverGroupReadWriteEndpoint.Serialization.cs @@ -116,28 +116,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverPolicy), out propertyOverride); if (Optional.IsDefined(FailoverPolicy) || hasPropertyOverride) { - builder.Append(" failoverPolicy:"); + builder.Append(" failoverPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverPolicy.ToString()}'"); + builder.AppendLine($"'{FailoverPolicy.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverWithDataLossGracePeriodMinutes), out propertyOverride); if (Optional.IsDefined(FailoverWithDataLossGracePeriodMinutes) || hasPropertyOverride) { - builder.Append(" failoverWithDataLossGracePeriodMinutes:"); + builder.Append(" failoverWithDataLossGracePeriodMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FailoverWithDataLossGracePeriodMinutes.Value}"); + builder.AppendLine($"{FailoverWithDataLossGracePeriodMinutes.Value}"); } } @@ -145,12 +145,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -171,13 +174,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolEditionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolEditionCapability.Serialization.cs index c580aa5b366c1..1b4ff7f5c0377 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolEditionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolEditionCapability.Serialization.cs @@ -114,7 +114,7 @@ internal static InstancePoolEditionCapability DeserializeInstancePoolEditionCapa List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstancePoolFamilyCapability.DeserializeInstancePoolFamilyCapability(item, options)); + array.Add(InstancePoolFamilyCapability.DeserializeInstancePoolFamilyCapability(item)); } supportedFamilies = array; continue; @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,17 +180,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedFamilies.Any() || hasPropertyOverride) { - builder.Append(" supportedFamilies:"); + builder.Append(" supportedFamilies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedFamilies) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedFamilies: "); } builder.AppendLine(" ]"); } @@ -200,35 +200,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -237,12 +237,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -263,13 +266,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolFamilyCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolFamilyCapability.Serialization.cs index e9d84df87bc29..24195919e7b99 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolFamilyCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolFamilyCapability.Serialization.cs @@ -125,7 +125,7 @@ internal static InstancePoolFamilyCapability DeserializeInstancePoolFamilyCapabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item, options)); + array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item)); } supportedLicenseTypes = array; continue; @@ -139,7 +139,7 @@ internal static InstancePoolFamilyCapability DeserializeInstancePoolFamilyCapabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstancePoolVcoresCapability.DeserializeInstancePoolVcoresCapability(item, options)); + array.Add(InstancePoolVcoresCapability.DeserializeInstancePoolVcoresCapability(item)); } supportedVcoresValues = array; continue; @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,17 +205,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedLicenseTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedLicenseTypes:"); + builder.Append(" supportedLicenseTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedLicenseTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedLicenseTypes: "); } builder.AppendLine(" ]"); } @@ -227,17 +227,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedVcoresValues.Any() || hasPropertyOverride) { - builder.Append(" supportedVcoresValues:"); + builder.Append(" supportedVcoresValues: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedVcoresValues) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedVcoresValues: "); } builder.AppendLine(" ]"); } @@ -247,35 +247,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -284,12 +284,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -310,13 +313,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolListResult.Serialization.cs index 9ac7789e8a3d8..440e69b34b2a7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static InstancePoolListResult DeserializeInstancePoolListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstancePoolData.DeserializeInstancePoolData(item, options)); + array.Add(InstancePoolData.DeserializeInstancePoolData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolPatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolPatch.Serialization.cs index ac73b71e640a6..8740692a154ab 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolPatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolPatch.Serialization.cs @@ -125,7 +125,7 @@ internal static InstancePoolPatch DeserializeInstancePoolPatch(JsonElement eleme { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsage.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsage.Serialization.cs index c1fed5b48d0fb..6f8a7e53ee232 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsage.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsage.Serialization.cs @@ -127,7 +127,7 @@ internal static InstancePoolUsage DeserializeInstancePoolUsage(JsonElement eleme { continue; } - name = InstancePoolUsageName.DeserializeInstancePoolUsageName(property.Value, options); + name = InstancePoolUsageName.DeserializeInstancePoolUsageName(property.Value); continue; } if (property.NameEquals("type"u8)) @@ -194,49 +194,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Name, options, 2, false); + AppendChildObject(builder, Name, options, 2, false, " name: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -244,42 +244,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentValue.Value}"); + builder.AppendLine($"{CurrentValue.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Limit.Value}"); + builder.AppendLine($"{Limit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedLimit), out propertyOverride); if (Optional.IsDefined(RequestedLimit) || hasPropertyOverride) { - builder.Append(" requestedLimit:"); + builder.Append(" requestedLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RequestedLimit.Value}"); + builder.AppendLine($"{RequestedLimit.Value}"); } } @@ -287,12 +287,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -313,13 +316,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageListResult.Serialization.cs index 19aba62e0ecf0..f56cac2d990f8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static InstancePoolUsageListResult DeserializeInstancePoolUsageListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstancePoolUsage.DeserializeInstancePoolUsage(item, options)); + array.Add(InstancePoolUsage.DeserializeInstancePoolUsage(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageName.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageName.Serialization.cs index fdea44d37051a..9fc82ea5ac5fa 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageName.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolUsageName.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalizedValue), out propertyOverride); if (Optional.IsDefined(LocalizedValue) || hasPropertyOverride) { - builder.Append(" localizedValue:"); + builder.Append(" localizedValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalizedValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalizedValue}'''"); } else { - builder.AppendLine($" '{LocalizedValue}'"); + builder.AppendLine($"'{LocalizedValue}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolVcoresCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolVcoresCapability.Serialization.cs index 23f187b2c0084..3ea59432abc09 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolVcoresCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/InstancePoolVcoresCapability.Serialization.cs @@ -120,7 +120,7 @@ internal static InstancePoolVcoresCapability DeserializeInstancePoolVcoresCapabi { continue; } - storageLimit = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + storageLimit = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("status"u8)) @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -182,63 +182,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Value.Value}"); + builder.AppendLine($"{Value.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageLimit), out propertyOverride); if (Optional.IsDefined(StorageLimit) || hasPropertyOverride) { - builder.Append(" storageLimit:"); + builder.Append(" storageLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StorageLimit, options, 2, false); + AppendChildObject(builder, StorageLimit, options, 2, false, " storageLimit: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobAgentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobAgentListResult.Serialization.cs index bee372acfe824..8296207fb2c62 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobAgentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobAgentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobAgentListResult DeserializeJobAgentListResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobAgentData.DeserializeSqlServerJobAgentData(item, options)); + array.Add(SqlServerJobAgentData.DeserializeSqlServerJobAgentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobCredentialListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobCredentialListResult.Serialization.cs index d660d4d53ad34..7282903466a6d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobCredentialListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobCredentialListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobCredentialListResult DeserializeJobCredentialListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobCredentialData.DeserializeSqlServerJobCredentialData(item, options)); + array.Add(SqlServerJobCredentialData.DeserializeSqlServerJobCredentialData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionListResult.Serialization.cs index 5a880f20bda17..27d0d2364338f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobExecutionListResult DeserializeJobExecutionListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobExecutionData.DeserializeSqlServerJobExecutionData(item, options)); + array.Add(SqlServerJobExecutionData.DeserializeSqlServerJobExecutionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionTarget.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionTarget.Serialization.cs index cd7b2606f6c4c..d9507d0c29fa8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionTarget.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobExecutionTarget.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobListResult.Serialization.cs index b1cd2e50b2a16..352f2ac62fe76 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobListResult DeserializeJobListResult(JsonElement element, Mode List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobData.DeserializeSqlServerJobData(item, options)); + array.Add(SqlServerJobData.DeserializeSqlServerJobData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepAction.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepAction.Serialization.cs index 8a8127bf3a4ee..4943adc0cd2f7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepAction.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepAction.Serialization.cs @@ -131,35 +131,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Source.Value.ToString()}'"); + builder.AppendLine($"'{Source.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepExecutionOptions.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepExecutionOptions.Serialization.cs index 31dd4d58d3107..34ea5f33d5cb5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepExecutionOptions.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepExecutionOptions.Serialization.cs @@ -168,70 +168,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutSeconds), out propertyOverride); if (Optional.IsDefined(TimeoutSeconds) || hasPropertyOverride) { - builder.Append(" timeoutSeconds:"); + builder.Append(" timeoutSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TimeoutSeconds.Value}"); + builder.AppendLine($"{TimeoutSeconds.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetryAttempts), out propertyOverride); if (Optional.IsDefined(RetryAttempts) || hasPropertyOverride) { - builder.Append(" retryAttempts:"); + builder.Append(" retryAttempts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetryAttempts.Value}"); + builder.AppendLine($"{RetryAttempts.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitialRetryIntervalSeconds), out propertyOverride); if (Optional.IsDefined(InitialRetryIntervalSeconds) || hasPropertyOverride) { - builder.Append(" initialRetryIntervalSeconds:"); + builder.Append(" initialRetryIntervalSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {InitialRetryIntervalSeconds.Value}"); + builder.AppendLine($"{InitialRetryIntervalSeconds.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumRetryIntervalSeconds), out propertyOverride); if (Optional.IsDefined(MaximumRetryIntervalSeconds) || hasPropertyOverride) { - builder.Append(" maximumRetryIntervalSeconds:"); + builder.Append(" maximumRetryIntervalSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumRetryIntervalSeconds.Value}"); + builder.AppendLine($"{MaximumRetryIntervalSeconds.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetryIntervalBackoffMultiplier), out propertyOverride); if (Optional.IsDefined(RetryIntervalBackoffMultiplier) || hasPropertyOverride) { - builder.Append(" retryIntervalBackoffMultiplier:"); + builder.Append(" retryIntervalBackoffMultiplier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RetryIntervalBackoffMultiplier.Value.ToString()}'"); + builder.AppendLine($"'{RetryIntervalBackoffMultiplier.Value.ToString()}'"); } } @@ -239,12 +239,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -265,13 +268,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepListResult.Serialization.cs index d33a265dfe787..ff033c360ae90 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobStepListResult DeserializeJobStepListResult(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobStepData.DeserializeSqlServerJobStepData(item, options)); + array.Add(SqlServerJobStepData.DeserializeSqlServerJobStepData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepOutput.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepOutput.Serialization.cs index 52af3fb0d8664..ff90695b9578e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepOutput.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobStepOutput.Serialization.cs @@ -177,35 +177,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) { - builder.Append(" subscriptionId:"); + builder.Append(" subscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{SubscriptionId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroupName), out propertyOverride); if (Optional.IsDefined(ResourceGroupName) || hasPropertyOverride) { - builder.Append(" resourceGroupName:"); + builder.Append(" resourceGroupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroupName}'''"); } else { - builder.AppendLine($" '{ResourceGroupName}'"); + builder.AppendLine($"'{ResourceGroupName}'"); } } } @@ -213,21 +213,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -235,21 +235,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -257,21 +257,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SchemaName), out propertyOverride); if (Optional.IsDefined(SchemaName) || hasPropertyOverride) { - builder.Append(" schemaName:"); + builder.Append(" schemaName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SchemaName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SchemaName}'''"); } else { - builder.AppendLine($" '{SchemaName}'"); + builder.AppendLine($"'{SchemaName}'"); } } } @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); if (Optional.IsDefined(TableName) || hasPropertyOverride) { - builder.Append(" tableName:"); + builder.Append(" tableName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TableName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TableName}'''"); } else { - builder.AppendLine($" '{TableName}'"); + builder.AppendLine($"'{TableName}'"); } } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credential), out propertyOverride); if (Optional.IsDefined(Credential) || hasPropertyOverride) { - builder.Append(" credential:"); + builder.Append(" credential: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Credential.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Credential}'''"); } else { - builder.AppendLine($" '{Credential}'"); + builder.AppendLine($"'{Credential}'"); } } } @@ -324,12 +324,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -350,13 +353,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTarget.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTarget.Serialization.cs index e2bf57353bcf9..f4b75bee8da2c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTarget.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTarget.Serialization.cs @@ -171,35 +171,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MembershipType), out propertyOverride); if (Optional.IsDefined(MembershipType) || hasPropertyOverride) { - builder.Append(" membershipType:"); + builder.Append(" membershipType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MembershipType.Value.ToSerialString()}'"); + builder.AppendLine($"'{MembershipType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticPoolName), out propertyOverride); if (Optional.IsDefined(ElasticPoolName) || hasPropertyOverride) { - builder.Append(" elasticPoolName:"); + builder.Append(" elasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ElasticPoolName}'''"); } else { - builder.AppendLine($" '{ElasticPoolName}'"); + builder.AppendLine($"'{ElasticPoolName}'"); } } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShardMapName), out propertyOverride); if (Optional.IsDefined(ShardMapName) || hasPropertyOverride) { - builder.Append(" shardMapName:"); + builder.Append(" shardMapName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ShardMapName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ShardMapName}'''"); } else { - builder.AppendLine($" '{ShardMapName}'"); + builder.AppendLine($"'{ShardMapName}'"); } } } @@ -273,21 +273,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RefreshCredential), out propertyOverride); if (Optional.IsDefined(RefreshCredential) || hasPropertyOverride) { - builder.Append(" refreshCredential:"); + builder.Append(" refreshCredential: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RefreshCredential.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RefreshCredential}'''"); } else { - builder.AppendLine($" '{RefreshCredential}'"); + builder.AppendLine($"'{RefreshCredential}'"); } } } @@ -296,12 +296,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -322,13 +325,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTargetGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTargetGroupListResult.Serialization.cs index 50d4de79a40b5..15395fba49098 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTargetGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobTargetGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobTargetGroupListResult DeserializeJobTargetGroupListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobTargetGroupData.DeserializeSqlServerJobTargetGroupData(item, options)); + array.Add(SqlServerJobTargetGroupData.DeserializeSqlServerJobTargetGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobVersionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobVersionListResult.Serialization.cs index ac9ccc00512a0..3968298333217 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobVersionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/JobVersionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static JobVersionListResult DeserializeJobVersionListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerJobVersionData.DeserializeSqlServerJobVersionData(item, options)); + array.Add(SqlServerJobVersionData.DeserializeSqlServerJobVersionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LedgerDigestUploadsListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LedgerDigestUploadsListResult.Serialization.cs index 36089e5f6fcdc..c764948720df6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LedgerDigestUploadsListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LedgerDigestUploadsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LedgerDigestUploadsListResult DeserializeLedgerDigestUploadsList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LedgerDigestUploadData.DeserializeLedgerDigestUploadData(item, options)); + array.Add(LedgerDigestUploadData.DeserializeLedgerDigestUploadData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LicenseTypeCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LicenseTypeCapability.Serialization.cs index b0bb623e80516..02259826de857 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LicenseTypeCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LicenseTypeCapability.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -152,35 +152,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogSizeCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogSizeCapability.Serialization.cs index d14684ca0a484..732b84c674e19 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogSizeCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogSizeCapability.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Limit.Value}"); + builder.AppendLine($"{Limit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalDatabaseTransparentDataEncryptionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalDatabaseTransparentDataEncryptionListResult.Serialization.cs index 4d9ecf963c1a5..2ab180ea1b631 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalDatabaseTransparentDataEncryptionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalDatabaseTransparentDataEncryptionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LogicalDatabaseTransparentDataEncryptionListResult DeserializeLo List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LogicalDatabaseTransparentDataEncryptionData.DeserializeLogicalDatabaseTransparentDataEncryptionData(item, options)); + array.Add(LogicalDatabaseTransparentDataEncryptionData.DeserializeLogicalDatabaseTransparentDataEncryptionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs index a247746289ab1..035aae0b62fb9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LogicalServerAdvancedThreatProtectionListResult DeserializeLogic List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(item, options)); + array.Add(ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerSecurityAlertPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerSecurityAlertPolicyListResult.Serialization.cs index 46ffeaf1a707f..394b3ae07d207 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerSecurityAlertPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerSecurityAlertPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LogicalServerSecurityAlertPolicyListResult DeserializeLogicalSer List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerSecurityAlertPolicyData.DeserializeSqlServerSecurityAlertPolicyData(item, options)); + array.Add(SqlServerSecurityAlertPolicyData.DeserializeSqlServerSecurityAlertPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupListResult.Serialization.cs index 5b803a6f56a6d..8f8988278c377 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LongTermRetentionBackupListResult DeserializeLongTermRetentionBa List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LongTermRetentionBackupData.DeserializeLongTermRetentionBackupData(item, options)); + array.Add(LongTermRetentionBackupData.DeserializeLongTermRetentionBackupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupOperationResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupOperationResult.Serialization.cs index abecaf8f17543..b760f9b41c877 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupOperationResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionBackupOperationResult.Serialization.cs @@ -250,21 +250,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -272,28 +272,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -302,35 +302,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestId), out propertyOverride); if (Optional.IsDefined(RequestId) || hasPropertyOverride) { - builder.Append(" requestId:"); + builder.Append(" requestId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestId.Value.ToString()}'"); + builder.AppendLine($"'{RequestId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationType), out propertyOverride); if (Optional.IsDefined(OperationType) || hasPropertyOverride) { - builder.Append(" operationType:"); + builder.Append(" operationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationType}'''"); } else { - builder.AppendLine($" '{OperationType}'"); + builder.AppendLine($"'{OperationType}'"); } } } @@ -338,63 +338,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FromBackupResourceId), out propertyOverride); if (Optional.IsDefined(FromBackupResourceId) || hasPropertyOverride) { - builder.Append(" fromBackupResourceId:"); + builder.Append(" fromBackupResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FromBackupResourceId.ToString()}'"); + builder.AppendLine($"'{FromBackupResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ToBackupResourceId), out propertyOverride); if (Optional.IsDefined(ToBackupResourceId) || hasPropertyOverride) { - builder.Append(" toBackupResourceId:"); + builder.Append(" toBackupResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ToBackupResourceId.ToString()}'"); + builder.AppendLine($"'{ToBackupResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(TargetBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" targetBackupStorageRedundancy:"); + builder.Append(" targetBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{TargetBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -402,21 +402,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -426,12 +426,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -452,13 +455,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionPolicyListResult.Serialization.cs index 94c46bbd88ec5..4f3384ad0b06b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LongTermRetentionPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static LongTermRetentionPolicyListResult DeserializeLongTermRetentionPo List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LongTermRetentionPolicyData.DeserializeLongTermRetentionPolicyData(item, options)); + array.Add(LongTermRetentionPolicyData.DeserializeLongTermRetentionPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceConfigurationCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceConfigurationCapability.Serialization.cs index 5cd5ac0bec0fa..75385171debfa 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceConfigurationCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceConfigurationCapability.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -167,50 +167,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -219,12 +219,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -245,13 +248,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceWindowTimeRange.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceWindowTimeRange.Serialization.cs index 0fd49c433f6e3..5a92a014d5210 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceWindowTimeRange.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaintenanceWindowTimeRange.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DayOfWeek), out propertyOverride); if (Optional.IsDefined(DayOfWeek) || hasPropertyOverride) { - builder.Append(" dayOfWeek:"); + builder.Append(" dayOfWeek: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DayOfWeek.Value.ToString()}'"); + builder.AppendLine($"'{DayOfWeek.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -170,15 +170,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Duration), out propertyOverride); if (Optional.IsDefined(Duration) || hasPropertyOverride) { - builder.Append(" duration:"); + builder.Append(" duration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Duration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedBackupShortTermRetentionPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedBackupShortTermRetentionPolicyListResult.Serialization.cs index 1cf37ebd83a43..dece8c81ee984 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedBackupShortTermRetentionPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedBackupShortTermRetentionPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedBackupShortTermRetentionPolicyListResult DeserializeManag List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedBackupShortTermRetentionPolicyData.DeserializeManagedBackupShortTermRetentionPolicyData(item, options)); + array.Add(ManagedBackupShortTermRetentionPolicyData.DeserializeManagedBackupShortTermRetentionPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseAdvancedThreatProtectionListResult.Serialization.cs index eb4569ee046e4..30ed283631ff0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseAdvancedThreatProtectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseAdvancedThreatProtectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedDatabaseAdvancedThreatProtectionListResult DeserializeMan List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedDatabaseAdvancedThreatProtectionData.DeserializeManagedDatabaseAdvancedThreatProtectionData(item, options)); + array.Add(ManagedDatabaseAdvancedThreatProtectionData.DeserializeManagedDatabaseAdvancedThreatProtectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseListResult.Serialization.cs index f686e955b5170..a555e0feda444 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedDatabaseListResult DeserializeManagedDatabaseListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedDatabaseData.DeserializeManagedDatabaseData(item, options)); + array.Add(ManagedDatabaseData.DeserializeManagedDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailBackupSetProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailBackupSetProperties.Serialization.cs index 94784a794b6be..0672732583d3c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailBackupSetProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailBackupSetProperties.Serialization.cs @@ -175,21 +175,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -197,21 +197,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FirstStripeName), out propertyOverride); if (Optional.IsDefined(FirstStripeName) || hasPropertyOverride) { - builder.Append(" firstStripeName:"); + builder.Append(" firstStripeName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FirstStripeName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FirstStripeName}'''"); } else { - builder.AppendLine($" '{FirstStripeName}'"); + builder.AppendLine($"'{FirstStripeName}'"); } } } @@ -219,58 +219,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfStripes), out propertyOverride); if (Optional.IsDefined(NumberOfStripes) || hasPropertyOverride) { - builder.Append(" numberOfStripes:"); + builder.Append(" numberOfStripes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfStripes.Value}"); + builder.AppendLine($"{NumberOfStripes.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupSizeInMB), out propertyOverride); if (Optional.IsDefined(BackupSizeInMB) || hasPropertyOverride) { - builder.Append(" backupSizeMB:"); + builder.Append(" backupSizeMB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {BackupSizeInMB.Value}"); + builder.AppendLine($"{BackupSizeInMB.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoreStartedOn), out propertyOverride); if (Optional.IsDefined(RestoreStartedOn) || hasPropertyOverride) { - builder.Append(" restoreStartedTimestampUtc:"); + builder.Append(" restoreStartedTimestampUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestoreStartedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoreFinishedOn), out propertyOverride); if (Optional.IsDefined(RestoreFinishedOn) || hasPropertyOverride) { - builder.Append(" restoreFinishedTimestampUtc:"); + builder.Append(" restoreFinishedTimestampUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestoreFinishedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -278,12 +278,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -304,13 +307,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailUnrestorableFileProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailUnrestorableFileProperties.Serialization.cs index 680fa0ae35f7f..d2cdf6c8747b3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailUnrestorableFileProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseRestoreDetailUnrestorableFileProperties.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseSecurityAlertPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseSecurityAlertPolicyListResult.Serialization.cs index bc0c588c6c6d4..10fa3bf9defb5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseSecurityAlertPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedDatabaseSecurityAlertPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedDatabaseSecurityAlertPolicyListResult DeserializeManagedD List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedDatabaseSecurityAlertPolicyData.DeserializeManagedDatabaseSecurityAlertPolicyData(item, options)); + array.Add(ManagedDatabaseSecurityAlertPolicyData.DeserializeManagedDatabaseSecurityAlertPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdministratorListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdministratorListResult.Serialization.cs index 7acc7b6a5dc6c..48119a4733a7f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdministratorListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdministratorListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceAdministratorListResult DeserializeManagedInstanc List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceAdministratorData.DeserializeManagedInstanceAdministratorData(item, options)); + array.Add(ManagedInstanceAdministratorData.DeserializeManagedInstanceAdministratorData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdvancedThreatProtectionListResult.Serialization.cs index 04583fcccb427..f155846f18747 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdvancedThreatProtectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAdvancedThreatProtectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceAdvancedThreatProtectionListResult DeserializeMan List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceAdvancedThreatProtectionData.DeserializeManagedInstanceAdvancedThreatProtectionData(item, options)); + array.Add(ManagedInstanceAdvancedThreatProtectionData.DeserializeManagedInstanceAdvancedThreatProtectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAzureADOnlyAuthListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAzureADOnlyAuthListResult.Serialization.cs index 9875dee40d0de..4e8c4c87ba5ff 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAzureADOnlyAuthListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceAzureADOnlyAuthListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceAzureADOnlyAuthListResult DeserializeManagedInsta List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceAzureADOnlyAuthenticationData.DeserializeManagedInstanceAzureADOnlyAuthenticationData(item, options)); + array.Add(ManagedInstanceAzureADOnlyAuthenticationData.DeserializeManagedInstanceAzureADOnlyAuthenticationData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcListResult.Serialization.cs index 35e63b18b3174..004c3a95f0b0a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceDtcListResult DeserializeManagedInstanceDtcListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceDtcData.DeserializeManagedInstanceDtcData(item, options)); + array.Add(ManagedInstanceDtcData.DeserializeManagedInstanceDtcData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcSecuritySettings.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcSecuritySettings.Serialization.cs index 2d1627b87f8b0..b8471823223af 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcSecuritySettings.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcSecuritySettings.Serialization.cs @@ -106,7 +106,7 @@ internal static ManagedInstanceDtcSecuritySettings DeserializeManagedInstanceDtc { continue; } - transactionManagerCommunicationSettings = ManagedInstanceDtcTransactionManagerCommunicationSettings.DeserializeManagedInstanceDtcTransactionManagerCommunicationSettings(property.Value, options); + transactionManagerCommunicationSettings = ManagedInstanceDtcTransactionManagerCommunicationSettings.DeserializeManagedInstanceDtcTransactionManagerCommunicationSettings(property.Value); continue; } if (property.NameEquals("xaTransactionsEnabled"u8)) @@ -168,72 +168,72 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TransactionManagerCommunicationSettings), out propertyOverride); if (Optional.IsDefined(TransactionManagerCommunicationSettings) || hasPropertyOverride) { - builder.Append(" transactionManagerCommunicationSettings:"); + builder.Append(" transactionManagerCommunicationSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TransactionManagerCommunicationSettings, options, 2, false); + AppendChildObject(builder, TransactionManagerCommunicationSettings, options, 2, false, " transactionManagerCommunicationSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsXATransactionsEnabled), out propertyOverride); if (Optional.IsDefined(IsXATransactionsEnabled) || hasPropertyOverride) { - builder.Append(" xaTransactionsEnabled:"); + builder.Append(" xaTransactionsEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsXATransactionsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnaLu6Point2TransactionsEnabled), out propertyOverride); if (Optional.IsDefined(SnaLu6Point2TransactionsEnabled) || hasPropertyOverride) { - builder.Append(" snaLu6point2TransactionsEnabled:"); + builder.Append(" snaLu6point2TransactionsEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SnaLu6Point2TransactionsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(XATransactionsDefaultTimeoutInSeconds), out propertyOverride); if (Optional.IsDefined(XATransactionsDefaultTimeoutInSeconds) || hasPropertyOverride) { - builder.Append(" xaTransactionsDefaultTimeout:"); + builder.Append(" xaTransactionsDefaultTimeout: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {XATransactionsDefaultTimeoutInSeconds.Value}"); + builder.AppendLine($"{XATransactionsDefaultTimeoutInSeconds.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(XATransactionsMaximumTimeoutInSeconds), out propertyOverride); if (Optional.IsDefined(XATransactionsMaximumTimeoutInSeconds) || hasPropertyOverride) { - builder.Append(" xaTransactionsMaximumTimeout:"); + builder.Append(" xaTransactionsMaximumTimeout: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {XATransactionsMaximumTimeoutInSeconds.Value}"); + builder.AppendLine($"{XATransactionsMaximumTimeoutInSeconds.Value}"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcTransactionManagerCommunicationSettings.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcTransactionManagerCommunicationSettings.Serialization.cs index 3d7618cb3de0a..bfa5d33539c2d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcTransactionManagerCommunicationSettings.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceDtcTransactionManagerCommunicationSettings.Serialization.cs @@ -134,51 +134,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowInboundEnabled), out propertyOverride); if (Optional.IsDefined(AllowInboundEnabled) || hasPropertyOverride) { - builder.Append(" allowInboundEnabled:"); + builder.Append(" allowInboundEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowInboundEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowOutboundEnabled), out propertyOverride); if (Optional.IsDefined(AllowOutboundEnabled) || hasPropertyOverride) { - builder.Append(" allowOutboundEnabled:"); + builder.Append(" allowOutboundEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowOutboundEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Authentication), out propertyOverride); if (Optional.IsDefined(Authentication) || hasPropertyOverride) { - builder.Append(" authentication:"); + builder.Append(" authentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Authentication.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Authentication}'''"); } else { - builder.AppendLine($" '{Authentication}'"); + builder.AppendLine($"'{Authentication}'"); } } } @@ -187,12 +187,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -213,13 +216,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEditionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEditionCapability.Serialization.cs index 6ba02eff876a9..01b295be3ff34 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEditionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEditionCapability.Serialization.cs @@ -131,7 +131,7 @@ internal static ManagedInstanceEditionCapability DeserializeManagedInstanceEditi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceFamilyCapability.DeserializeManagedInstanceFamilyCapability(item, options)); + array.Add(ManagedInstanceFamilyCapability.DeserializeManagedInstanceFamilyCapability(item)); } supportedFamilies = array; continue; @@ -145,7 +145,7 @@ internal static ManagedInstanceEditionCapability DeserializeManagedInstanceEditi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageCapability.DeserializeStorageCapability(item, options)); + array.Add(StorageCapability.DeserializeStorageCapability(item)); } supportedStorageCapabilities = array; continue; @@ -196,21 +196,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,17 +220,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedFamilies.Any() || hasPropertyOverride) { - builder.Append(" supportedFamilies:"); + builder.Append(" supportedFamilies: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedFamilies) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedFamilies: "); } builder.AppendLine(" ]"); } @@ -242,17 +242,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedStorageCapabilities.Any() || hasPropertyOverride) { - builder.Append(" supportedStorageCapabilities:"); + builder.Append(" supportedStorageCapabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedStorageCapabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedStorageCapabilities: "); } builder.AppendLine(" ]"); } @@ -262,50 +262,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -314,12 +314,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -340,13 +343,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEncryptionProtectorListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEncryptionProtectorListResult.Serialization.cs index 3453fc3fdb016..8da550f742fc5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEncryptionProtectorListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEncryptionProtectorListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceEncryptionProtectorListResult DeserializeManagedI List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceEncryptionProtectorData.DeserializeManagedInstanceEncryptionProtectorData(item, options)); + array.Add(ManagedInstanceEncryptionProtectorData.DeserializeManagedInstanceEncryptionProtectorData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDependency.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDependency.Serialization.cs index beea82ca8eed5..c40e6ced0e671 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDependency.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDependency.Serialization.cs @@ -102,7 +102,7 @@ internal static ManagedInstanceEndpointDependency DeserializeManagedInstanceEndp List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceEndpointDetail.DeserializeManagedInstanceEndpointDetail(item, options)); + array.Add(ManagedInstanceEndpointDetail.DeserializeManagedInstanceEndpointDetail(item)); } endpointDetails = array; continue; @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainName), out propertyOverride); if (Optional.IsDefined(DomainName) || hasPropertyOverride) { - builder.Append(" domainName:"); + builder.Append(" domainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainName}'''"); } else { - builder.AppendLine($" '{DomainName}'"); + builder.AppendLine($"'{DomainName}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EndpointDetails.Any() || hasPropertyOverride) { - builder.Append(" endpointDetails:"); + builder.Append(" endpointDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EndpointDetails) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " endpointDetails: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDetail.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDetail.Serialization.cs index 99340107f7cbc..0cd49573bba76 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDetail.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceEndpointDetail.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); if (Optional.IsDefined(Port) || hasPropertyOverride) { - builder.Append(" port:"); + builder.Append(" port: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Port.Value}"); + builder.AppendLine($"{Port.Value}"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceExternalAdministrator.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceExternalAdministrator.Serialization.cs index 1af5b43b8c990..c4f35abc6152e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceExternalAdministrator.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceExternalAdministrator.Serialization.cs @@ -179,49 +179,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) { - builder.Append(" administratorType:"); + builder.Append(" administratorType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AdministratorType.Value.ToString()}'"); + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalType), out propertyOverride); if (Optional.IsDefined(PrincipalType) || hasPropertyOverride) { - builder.Append(" principalType:"); + builder.Append(" principalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalType.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Login.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Login}'''"); } else { - builder.AppendLine($" '{Login}'"); + builder.AppendLine($"'{Login}'"); } } } @@ -229,43 +229,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); if (Optional.IsDefined(Sid) || hasPropertyOverride) { - builder.Append(" sid:"); + builder.Append(" sid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Sid.Value.ToString()}'"); + builder.AppendLine($"'{Sid.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureADOnlyAuthenticationEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureADOnlyAuthenticationEnabled) || hasPropertyOverride) { - builder.Append(" azureADOnlyAuthentication:"); + builder.Append(" azureADOnlyAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureADOnlyAuthenticationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -273,12 +273,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -299,13 +302,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceFamilyCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceFamilyCapability.Serialization.cs index 2861745022ca1..57296f59457a7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceFamilyCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceFamilyCapability.Serialization.cs @@ -136,7 +136,7 @@ internal static ManagedInstanceFamilyCapability DeserializeManagedInstanceFamily List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item, options)); + array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item)); } supportedLicenseTypes = array; continue; @@ -150,7 +150,7 @@ internal static ManagedInstanceFamilyCapability DeserializeManagedInstanceFamily List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceVcoresCapability.DeserializeManagedInstanceVcoresCapability(item, options)); + array.Add(ManagedInstanceVcoresCapability.DeserializeManagedInstanceVcoresCapability(item)); } supportedVcoresValues = array; continue; @@ -192,21 +192,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -214,21 +214,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Sku.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Sku}'''"); } else { - builder.AppendLine($" '{Sku}'"); + builder.AppendLine($"'{Sku}'"); } } } @@ -238,17 +238,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedLicenseTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedLicenseTypes:"); + builder.Append(" supportedLicenseTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedLicenseTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedLicenseTypes: "); } builder.AppendLine(" ]"); } @@ -260,17 +260,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedVcoresValues.Any() || hasPropertyOverride) { - builder.Append(" supportedVcoresValues:"); + builder.Append(" supportedVcoresValues: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedVcoresValues) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedVcoresValues: "); } builder.AppendLine(" ]"); } @@ -280,35 +280,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -317,12 +317,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -343,13 +346,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceKeyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceKeyListResult.Serialization.cs index 4fda69c9c8882..02b86ac6e28a3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceKeyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceKeyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceKeyListResult DeserializeManagedInstanceKeyListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceKeyData.DeserializeManagedInstanceKeyData(item, options)); + array.Add(ManagedInstanceKeyData.DeserializeManagedInstanceKeyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceListResult.Serialization.cs index bce17adeef17e..8dc6abb0f8229 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceListResult DeserializeManagedInstanceListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceData.DeserializeManagedInstanceData(item, options)); + array.Add(ManagedInstanceData.DeserializeManagedInstanceData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionBackupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionBackupListResult.Serialization.cs index 98481f9915ca2..f485ebd862164 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionBackupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionBackupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceLongTermRetentionBackupListResult DeserializeMana List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceLongTermRetentionBackupData.DeserializeManagedInstanceLongTermRetentionBackupData(item, options)); + array.Add(ManagedInstanceLongTermRetentionBackupData.DeserializeManagedInstanceLongTermRetentionBackupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionPolicyListResult.Serialization.cs index 607016158dff8..9294aa669bf42 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceLongTermRetentionPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceLongTermRetentionPolicyListResult DeserializeMana List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceLongTermRetentionPolicyData.DeserializeManagedInstanceLongTermRetentionPolicyData(item, options)); + array.Add(ManagedInstanceLongTermRetentionPolicyData.DeserializeManagedInstanceLongTermRetentionPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceMaintenanceConfigurationCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceMaintenanceConfigurationCapability.Serialization.cs index 295ba5ddfc87e..7c214ebf7d270 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceMaintenanceConfigurationCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceMaintenanceConfigurationCapability.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -152,35 +152,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationListResult.Serialization.cs index a480640b19644..49ae96afdf432 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceOperationListResult DeserializeManagedInstanceOpe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceOperationData.DeserializeManagedInstanceOperationData(item, options)); + array.Add(ManagedInstanceOperationData.DeserializeManagedInstanceOperationData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationParametersPair.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationParametersPair.Serialization.cs index 245ce772ed7c8..9ee8b9f1231e9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationParametersPair.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationParametersPair.Serialization.cs @@ -88,7 +88,7 @@ internal static ManagedInstanceOperationParametersPair DeserializeManagedInstanc { continue; } - currentParameters = UpsertManagedServerOperationParameters.DeserializeUpsertManagedServerOperationParameters(property.Value, options); + currentParameters = UpsertManagedServerOperationParameters.DeserializeUpsertManagedServerOperationParameters(property.Value); continue; } if (property.NameEquals("requestedParameters"u8)) @@ -97,7 +97,7 @@ internal static ManagedInstanceOperationParametersPair DeserializeManagedInstanc { continue; } - requestedParameters = UpsertManagedServerOperationParameters.DeserializeUpsertManagedServerOperationParameters(property.Value, options); + requestedParameters = UpsertManagedServerOperationParameters.DeserializeUpsertManagedServerOperationParameters(property.Value); continue; } if (options.Format != "W") @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentParameters), out propertyOverride); if (Optional.IsDefined(CurrentParameters) || hasPropertyOverride) { - builder.Append(" currentParameters:"); + builder.Append(" currentParameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CurrentParameters, options, 2, false); + AppendChildObject(builder, CurrentParameters, options, 2, false, " currentParameters: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedParameters), out propertyOverride); if (Optional.IsDefined(RequestedParameters) || hasPropertyOverride) { - builder.Append(" requestedParameters:"); + builder.Append(" requestedParameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RequestedParameters, options, 2, false); + AppendChildObject(builder, RequestedParameters, options, 2, false, " requestedParameters: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationSteps.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationSteps.Serialization.cs index 38afa0409bdca..a647bfbaa8739 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationSteps.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceOperationSteps.Serialization.cs @@ -117,7 +117,7 @@ internal static ManagedInstanceOperationSteps DeserializeManagedInstanceOperatio List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(UpsertManagedServerOperationStep.DeserializeUpsertManagedServerOperationStep(item, options)); + array.Add(UpsertManagedServerOperationStep.DeserializeUpsertManagedServerOperationStep(item)); } stepsList = array; continue; @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalSteps), out propertyOverride); if (Optional.IsDefined(TotalSteps) || hasPropertyOverride) { - builder.Append(" totalSteps:"); + builder.Append(" totalSteps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TotalSteps.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TotalSteps}'''"); } else { - builder.AppendLine($" '{TotalSteps}'"); + builder.AppendLine($"'{TotalSteps}'"); } } } @@ -167,14 +167,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentStep), out propertyOverride); if (Optional.IsDefined(CurrentStep) || hasPropertyOverride) { - builder.Append(" currentStep:"); + builder.Append(" currentStep: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentStep.Value}"); + builder.AppendLine($"{CurrentStep.Value}"); } } @@ -183,17 +183,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (StepsList.Any() || hasPropertyOverride) { - builder.Append(" stepsList:"); + builder.Append(" stepsList: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in StepsList) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " stepsList: "); } builder.AppendLine(" ]"); } @@ -204,12 +204,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -230,13 +233,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePairInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePairInfo.Serialization.cs index 93fa8a43fef29..7573401ffc431 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePairInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePairInfo.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryManagedInstanceId), out propertyOverride); if (Optional.IsDefined(PrimaryManagedInstanceId) || hasPropertyOverride) { - builder.Append(" primaryManagedInstanceId:"); + builder.Append(" primaryManagedInstanceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryManagedInstanceId.ToString()}'"); + builder.AppendLine($"'{PrimaryManagedInstanceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerManagedInstanceId), out propertyOverride); if (Optional.IsDefined(PartnerManagedInstanceId) || hasPropertyOverride) { - builder.Append(" partnerManagedInstanceId:"); + builder.Append(" partnerManagedInstanceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PartnerManagedInstanceId.ToString()}'"); + builder.AppendLine($"'{PartnerManagedInstanceId.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePatch.Serialization.cs index 39c627f24122e..b6bda727cd853 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePatch.Serialization.cs @@ -282,7 +282,7 @@ internal static ManagedInstancePatch DeserializeManagedInstancePatch(JsonElement { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("identity"u8)) @@ -479,7 +479,7 @@ internal static ManagedInstancePatch DeserializeManagedInstancePatch(JsonElement List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ManagedInstancePecProperty.DeserializeManagedInstancePecProperty(item, options)); + array.Add(ManagedInstancePecProperty.DeserializeManagedInstancePecProperty(item)); } privateEndpointConnections = array; continue; @@ -540,7 +540,7 @@ internal static ManagedInstancePatch DeserializeManagedInstancePatch(JsonElement { continue; } - administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value, options); + administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value); continue; } if (property0.NameEquals("servicePrincipal"u8)) @@ -549,7 +549,7 @@ internal static ManagedInstancePatch DeserializeManagedInstancePatch(JsonElement { continue; } - servicePrincipal = SqlServicePrincipal.DeserializeSqlServicePrincipal(property0.Value, options); + servicePrincipal = SqlServicePrincipal.DeserializeSqlServicePrincipal(property0.Value); continue; } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePecProperty.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePecProperty.Serialization.cs index 38093b9f6fec3..1446991de821d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePecProperty.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePecProperty.Serialization.cs @@ -97,7 +97,7 @@ internal static ManagedInstancePecProperty DeserializeManagedInstancePecProperty { continue; } - properties = ManagedInstancePrivateEndpointConnectionProperties.DeserializeManagedInstancePrivateEndpointConnectionProperties(property.Value, options); + properties = ManagedInstancePrivateEndpointConnectionProperties.DeserializeManagedInstancePrivateEndpointConnectionProperties(property.Value); continue; } if (options.Format != "W") @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionListResult.Serialization.cs index bf93b6283a22e..a39d45a131f9d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstancePrivateEndpointConnectionListResult DeserializeMa List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstancePrivateEndpointConnectionData.DeserializeManagedInstancePrivateEndpointConnectionData(item, options)); + array.Add(ManagedInstancePrivateEndpointConnectionData.DeserializeManagedInstancePrivateEndpointConnectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionProperties.Serialization.cs index d9715ce825cc4..3f18bd4683f50 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateEndpointConnectionProperties.Serialization.cs @@ -104,7 +104,7 @@ internal static ManagedInstancePrivateEndpointConnectionProperties DeserializeMa { continue; } - privateLinkServiceConnectionState = ManagedInstancePrivateLinkServiceConnectionStateProperty.DeserializeManagedInstancePrivateLinkServiceConnectionStateProperty(property.Value, options); + privateLinkServiceConnectionState = ManagedInstancePrivateLinkServiceConnectionStateProperty.DeserializeManagedInstancePrivateLinkServiceConnectionStateProperty(property.Value); continue; } if (property.NameEquals("provisioningState"u8)) @@ -135,49 +135,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 2, false); + AppendChildObject(builder, PrivateEndpoint, options, 2, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 2, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 2, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkListResult.Serialization.cs index 62757b08b935b..9f9d97895eaec 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstancePrivateLinkListResult DeserializeManagedInstanceP List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstancePrivateLinkData.DeserializeManagedInstancePrivateLinkData(item, options)); + array.Add(ManagedInstancePrivateLinkData.DeserializeManagedInstancePrivateLinkData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkProperties.Serialization.cs index 14b7557fa1a45..3643bc612b098 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkProperties.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -154,14 +154,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -188,12 +188,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -214,13 +217,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkServiceConnectionStateProperty.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkServiceConnectionStateProperty.Serialization.cs index bbfa3f507a659..25a32b6087609 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkServiceConnectionStateProperty.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePrivateLinkServiceConnectionStateProperty.Serialization.cs @@ -120,21 +120,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -142,21 +142,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -164,21 +164,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionsRequired.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionsRequired}'''"); } else { - builder.AppendLine($" '{ActionsRequired}'"); + builder.AppendLine($"'{ActionsRequired}'"); } } } @@ -187,12 +187,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -213,13 +216,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQuery.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQuery.Serialization.cs index 253c923fef84d..4ff04b707ae2f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQuery.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQuery.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryText), out propertyOverride); if (Optional.IsDefined(QueryText) || hasPropertyOverride) { - builder.Append(" queryText:"); + builder.Append(" queryText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueryText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueryText}'''"); } else { - builder.AppendLine($" '{QueryText}'"); + builder.AppendLine($"'{QueryText}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQueryStatistics.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQueryStatistics.Serialization.cs index 9c1210537ccd1..2fd13e80bc9c5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQueryStatistics.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceQueryStatistics.Serialization.cs @@ -97,7 +97,7 @@ internal static ManagedInstanceQueryStatistics DeserializeManagedInstanceQuerySt List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryStatistics.DeserializeQueryStatistics(item, options)); + array.Add(QueryStatistics.DeserializeQueryStatistics(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdateDnsServersOperationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdateDnsServersOperationData.Serialization.cs index 3f9df44aedc2a..91a153450c679 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdateDnsServersOperationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdateDnsServersOperationData.Serialization.cs @@ -172,21 +172,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -194,28 +194,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -224,14 +224,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } @@ -240,12 +240,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -266,13 +269,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVcoresCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVcoresCapability.Serialization.cs index c777475ee3ba2..4a1f3e56cd6b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVcoresCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVcoresCapability.Serialization.cs @@ -155,7 +155,7 @@ internal static ManagedInstanceVcoresCapability DeserializeManagedInstanceVcores { continue; } - includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("supportedStorageSizes"u8)) @@ -167,7 +167,7 @@ internal static ManagedInstanceVcoresCapability DeserializeManagedInstanceVcores List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item, options)); + array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item)); } supportedStorageSizes = array; continue; @@ -199,7 +199,7 @@ internal static ManagedInstanceVcoresCapability DeserializeManagedInstanceVcores List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceMaintenanceConfigurationCapability.DeserializeManagedInstanceMaintenanceConfigurationCapability(item, options)); + array.Add(ManagedInstanceMaintenanceConfigurationCapability.DeserializeManagedInstanceMaintenanceConfigurationCapability(item)); } supportedMaintenanceConfigurations = array; continue; @@ -241,21 +241,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -263,28 +263,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Value.Value}"); + builder.AppendLine($"{Value.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludedMaxSize), out propertyOverride); if (Optional.IsDefined(IncludedMaxSize) || hasPropertyOverride) { - builder.Append(" includedMaxSize:"); + builder.Append(" includedMaxSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IncludedMaxSize, options, 2, false); + AppendChildObject(builder, IncludedMaxSize, options, 2, false, " includedMaxSize: "); } } @@ -293,17 +293,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedStorageSizes.Any() || hasPropertyOverride) { - builder.Append(" supportedStorageSizes:"); + builder.Append(" supportedStorageSizes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedStorageSizes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedStorageSizes: "); } builder.AppendLine(" ]"); } @@ -313,30 +313,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInstancePoolSupported), out propertyOverride); if (Optional.IsDefined(IsInstancePoolSupported) || hasPropertyOverride) { - builder.Append(" instancePoolSupported:"); + builder.Append(" instancePoolSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInstancePoolSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStandaloneSupported), out propertyOverride); if (Optional.IsDefined(IsStandaloneSupported) || hasPropertyOverride) { - builder.Append(" standaloneSupported:"); + builder.Append(" standaloneSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStandaloneSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -345,17 +345,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMaintenanceConfigurations.Any() || hasPropertyOverride) { - builder.Append(" supportedMaintenanceConfigurations:"); + builder.Append(" supportedMaintenanceConfigurations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMaintenanceConfigurations) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMaintenanceConfigurations: "); } builder.AppendLine(" ]"); } @@ -365,35 +365,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -402,12 +402,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -428,13 +431,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVersionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVersionCapability.Serialization.cs index c370fd62da19f..53c9194b5327d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVersionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVersionCapability.Serialization.cs @@ -125,7 +125,7 @@ internal static ManagedInstanceVersionCapability DeserializeManagedInstanceVersi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceEditionCapability.DeserializeManagedInstanceEditionCapability(item, options)); + array.Add(ManagedInstanceEditionCapability.DeserializeManagedInstanceEditionCapability(item)); } supportedEditions = array; continue; @@ -139,7 +139,7 @@ internal static ManagedInstanceVersionCapability DeserializeManagedInstanceVersi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InstancePoolEditionCapability.DeserializeInstancePoolEditionCapability(item, options)); + array.Add(InstancePoolEditionCapability.DeserializeInstancePoolEditionCapability(item)); } supportedInstancePoolEditions = array; continue; @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,17 +205,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedEditions.Any() || hasPropertyOverride) { - builder.Append(" supportedEditions:"); + builder.Append(" supportedEditions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedEditions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedEditions: "); } builder.AppendLine(" ]"); } @@ -227,17 +227,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedInstancePoolEditions.Any() || hasPropertyOverride) { - builder.Append(" supportedInstancePoolEditions:"); + builder.Append(" supportedInstancePoolEditions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedInstancePoolEditions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedInstancePoolEditions: "); } builder.AppendLine(" ]"); } @@ -247,35 +247,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -284,12 +284,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -310,13 +313,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVulnerabilityAssessmentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVulnerabilityAssessmentListResult.Serialization.cs index 033f969994436..43f92d0e6d117 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVulnerabilityAssessmentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceVulnerabilityAssessmentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedInstanceVulnerabilityAssessmentListResult DeserializeMana List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceVulnerabilityAssessmentData.DeserializeManagedInstanceVulnerabilityAssessmentData(item, options)); + array.Add(ManagedInstanceVulnerabilityAssessmentData.DeserializeManagedInstanceVulnerabilityAssessmentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedLedgerDigestUploadsListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedLedgerDigestUploadsListResult.Serialization.cs index d872039706c90..11245ef6eeb3f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedLedgerDigestUploadsListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedLedgerDigestUploadsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedLedgerDigestUploadsListResult DeserializeManagedLedgerDig List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedLedgerDigestUploadData.DeserializeManagedLedgerDigestUploadData(item, options)); + array.Add(ManagedLedgerDigestUploadData.DeserializeManagedLedgerDigestUploadData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs index fd7195877c8bc..a699f5387eec0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedServerDnsAliasListResult DeserializeManagedServerDnsAlias List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(item, options)); + array.Add(ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerSecurityAlertPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerSecurityAlertPolicyListResult.Serialization.cs index 27931a94912b3..2e846f663fee1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerSecurityAlertPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerSecurityAlertPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedServerSecurityAlertPolicyListResult DeserializeManagedSer List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedServerSecurityAlertPolicyData.DeserializeManagedServerSecurityAlertPolicyData(item, options)); + array.Add(ManagedServerSecurityAlertPolicyData.DeserializeManagedServerSecurityAlertPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedTransparentDataEncryptionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedTransparentDataEncryptionListResult.Serialization.cs index 0067125f43e08..2029a2d5bd93d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedTransparentDataEncryptionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedTransparentDataEncryptionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ManagedTransparentDataEncryptionListResult DeserializeManagedTra List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedTransparentDataEncryptionData.DeserializeManagedTransparentDataEncryptionData(item, options)); + array.Add(ManagedTransparentDataEncryptionData.DeserializeManagedTransparentDataEncryptionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeCapability.Serialization.cs index 40abf027b89f4..234d815f4afa4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeCapability.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Limit.Value}"); + builder.AppendLine($"{Limit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeRangeCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeRangeCapability.Serialization.cs index 92f21ae64b16d..cb5c7c65bb2b1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeRangeCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MaxSizeRangeCapability.Serialization.cs @@ -112,7 +112,7 @@ internal static MaxSizeRangeCapability DeserializeMaxSizeRangeCapability(JsonEle { continue; } - minValue = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + minValue = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("maxValue"u8)) @@ -121,7 +121,7 @@ internal static MaxSizeRangeCapability DeserializeMaxSizeRangeCapability(JsonEle { continue; } - maxValue = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + maxValue = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("scaleSize"u8)) @@ -130,7 +130,7 @@ internal static MaxSizeRangeCapability DeserializeMaxSizeRangeCapability(JsonEle { continue; } - scaleSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + scaleSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("logSize"u8)) @@ -139,7 +139,7 @@ internal static MaxSizeRangeCapability DeserializeMaxSizeRangeCapability(JsonEle { continue; } - logSize = LogSizeCapability.DeserializeLogSizeCapability(property.Value, options); + logSize = LogSizeCapability.DeserializeLogSizeCapability(property.Value); continue; } if (property.NameEquals("status"u8)) @@ -179,91 +179,91 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinValue), out propertyOverride); if (Optional.IsDefined(MinValue) || hasPropertyOverride) { - builder.Append(" minValue:"); + builder.Append(" minValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MinValue, options, 2, false); + AppendChildObject(builder, MinValue, options, 2, false, " minValue: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxValue), out propertyOverride); if (Optional.IsDefined(MaxValue) || hasPropertyOverride) { - builder.Append(" maxValue:"); + builder.Append(" maxValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MaxValue, options, 2, false); + AppendChildObject(builder, MaxValue, options, 2, false, " maxValue: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScaleSize), out propertyOverride); if (Optional.IsDefined(ScaleSize) || hasPropertyOverride) { - builder.Append(" scaleSize:"); + builder.Append(" scaleSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ScaleSize, options, 2, false); + AppendChildObject(builder, ScaleSize, options, 2, false, " scaleSize: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogSize), out propertyOverride); if (Optional.IsDefined(LogSize) || hasPropertyOverride) { - builder.Append(" logSize:"); + builder.Append(" logSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LogSize, options, 2, false); + AppendChildObject(builder, LogSize, options, 2, false, " logSize: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -272,12 +272,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -298,13 +301,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MetricDefinitionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MetricDefinitionListResult.Serialization.cs index 43a3e60059752..ef3600fffdd15 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MetricDefinitionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MetricDefinitionListResult.Serialization.cs @@ -84,7 +84,7 @@ internal static MetricDefinitionListResult DeserializeMetricDefinitionListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlMetricDefinition.DeserializeSqlMetricDefinition(item, options)); + array.Add(SqlMetricDefinition.DeserializeSqlMetricDefinition(item)); } value = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MinCapacityCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MinCapacityCapability.Serialization.cs index e77fd42fd708b..b809746f94978 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MinCapacityCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/MinCapacityCapability.Serialization.cs @@ -134,49 +134,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.Value.ToString()}'"); + builder.AppendLine($"'{Value.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OutboundFirewallRuleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OutboundFirewallRuleListResult.Serialization.cs index 0578f31940b67..71bc3a008f36f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OutboundFirewallRuleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OutboundFirewallRuleListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static OutboundFirewallRuleListResult DeserializeOutboundFirewallRuleLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutboundFirewallRuleData.DeserializeOutboundFirewallRuleData(item, options)); + array.Add(OutboundFirewallRuleData.DeserializeOutboundFirewallRuleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerRegionInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerRegionInfo.Serialization.cs index 72f8b5b161141..a8dd031eede5c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerRegionInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerRegionInfo.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) { - builder.Append(" replicationRole:"); + builder.Append(" replicationRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationRole.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationRole.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerServerInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerServerInfo.Serialization.cs index 1e4f45dfb58d7..7697d79c53cee 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerServerInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PartnerServerInfo.Serialization.cs @@ -131,42 +131,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) { - builder.Append(" replicationRole:"); + builder.Append(" replicationRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationRole.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationRole.Value.ToString()}'"); } } @@ -174,12 +174,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -200,13 +203,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PerformanceLevelCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PerformanceLevelCapability.Serialization.cs index fb077482205e0..0f2e140480d60 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PerformanceLevelCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PerformanceLevelCapability.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.Value.ToString()}'"); + builder.AppendLine($"'{Value.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PrivateEndpointConnectionRequestStatus.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PrivateEndpointConnectionRequestStatus.Serialization.cs index b432363272d40..877e6ad3507be 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PrivateEndpointConnectionRequestStatus.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/PrivateEndpointConnectionRequestStatus.Serialization.cs @@ -130,35 +130,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceId), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceId) || hasPropertyOverride) { - builder.Append(" privateLinkServiceId:"); + builder.Append(" privateLinkServiceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrivateLinkServiceId.ToString()}'"); + builder.AppendLine($"'{PrivateLinkServiceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointConnectionName), out propertyOverride); if (Optional.IsDefined(PrivateEndpointConnectionName) || hasPropertyOverride) { - builder.Append(" privateEndpointConnectionName:"); + builder.Append(" privateEndpointConnectionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrivateEndpointConnectionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrivateEndpointConnectionName}'''"); } else { - builder.AppendLine($" '{PrivateEndpointConnectionName}'"); + builder.AppendLine($"'{PrivateEndpointConnectionName}'"); } } } @@ -166,21 +166,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ProxyResourceWithWritableName.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ProxyResourceWithWritableName.Serialization.cs index db4d12967cedc..9addb0363ba7d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ProxyResourceWithWritableName.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ProxyResourceWithWritableName.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,14 +156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricInterval.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricInterval.Serialization.cs index 4105c810b1204..e5a7139b87f76 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricInterval.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricInterval.Serialization.cs @@ -132,7 +132,7 @@ internal static QueryMetricInterval DeserializeQueryMetricInterval(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryMetricProperties.DeserializeQueryMetricProperties(item, options)); + array.Add(QueryMetricProperties.DeserializeQueryMetricProperties(item)); } metrics = array; continue; @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IntervalStartTime), out propertyOverride); if (Optional.IsDefined(IntervalStartTime) || hasPropertyOverride) { - builder.Append(" intervalStartTime:"); + builder.Append(" intervalStartTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (IntervalStartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{IntervalStartTime}'''"); } else { - builder.AppendLine($" '{IntervalStartTime}'"); + builder.AppendLine($"'{IntervalStartTime}'"); } } } @@ -182,28 +182,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IntervalType), out propertyOverride); if (Optional.IsDefined(IntervalType) || hasPropertyOverride) { - builder.Append(" intervalType:"); + builder.Append(" intervalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IntervalType.Value.ToString()}'"); + builder.AppendLine($"'{IntervalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecutionCount), out propertyOverride); if (Optional.IsDefined(ExecutionCount) || hasPropertyOverride) { - builder.Append(" executionCount:"); + builder.Append(" executionCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExecutionCount.Value.ToString()}'"); + builder.AppendLine($"'{ExecutionCount.Value.ToString()}'"); } } @@ -212,17 +212,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metrics.Any() || hasPropertyOverride) { - builder.Append(" metrics:"); + builder.Append(" metrics: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Metrics) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " metrics: "); } builder.AppendLine(" ]"); } @@ -233,12 +233,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -259,13 +262,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricProperties.Serialization.cs index 1a228f81798e5..6c6c2baa8cea4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryMetricProperties.Serialization.cs @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -264,98 +264,98 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.Value.ToString()}'"); + builder.AppendLine($"'{Value.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Min), out propertyOverride); if (Optional.IsDefined(Min) || hasPropertyOverride) { - builder.Append(" min:"); + builder.Append(" min: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Min.Value.ToString()}'"); + builder.AppendLine($"'{Min.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Max), out propertyOverride); if (Optional.IsDefined(Max) || hasPropertyOverride) { - builder.Append(" max:"); + builder.Append(" max: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Max.Value.ToString()}'"); + builder.AppendLine($"'{Max.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Avg), out propertyOverride); if (Optional.IsDefined(Avg) || hasPropertyOverride) { - builder.Append(" avg:"); + builder.Append(" avg: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Avg.Value.ToString()}'"); + builder.AppendLine($"'{Avg.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sum), out propertyOverride); if (Optional.IsDefined(Sum) || hasPropertyOverride) { - builder.Append(" sum:"); + builder.Append(" sum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Sum.Value.ToString()}'"); + builder.AppendLine($"'{Sum.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Stdev), out propertyOverride); if (Optional.IsDefined(Stdev) || hasPropertyOverride) { - builder.Append(" stdev:"); + builder.Append(" stdev: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Stdev.Value.ToString()}'"); + builder.AppendLine($"'{Stdev.Value.ToString()}'"); } } @@ -363,12 +363,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -389,13 +392,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatistics.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatistics.Serialization.cs index 5056b8e4462b5..5590296ee1cab 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatistics.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatistics.Serialization.cs @@ -196,7 +196,7 @@ internal static QueryStatistics DeserializeQueryStatistics(JsonElement element, List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(QueryMetricInterval.DeserializeQueryMetricInterval(item, options)); + array.Add(QueryMetricInterval.DeserializeQueryMetricInterval(item)); } intervals = array; continue; @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -249,28 +249,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryId), out propertyOverride); if (Optional.IsDefined(QueryId) || hasPropertyOverride) { - builder.Append(" queryId:"); + builder.Append(" queryId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueryId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueryId}'''"); } else { - builder.AppendLine($" '{QueryId}'"); + builder.AppendLine($"'{QueryId}'"); } } } @@ -323,21 +323,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -345,21 +345,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndTime), out propertyOverride); if (Optional.IsDefined(EndTime) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndTime}'''"); } else { - builder.AppendLine($" '{EndTime}'"); + builder.AppendLine($"'{EndTime}'"); } } } @@ -369,17 +369,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Intervals.Any() || hasPropertyOverride) { - builder.Append(" intervals:"); + builder.Append(" intervals: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Intervals) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " intervals: "); } builder.AppendLine(" ]"); } @@ -391,12 +391,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -417,13 +420,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatisticsProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatisticsProperties.Serialization.cs index 6ba012c4ba950..f681ec0e5e0fb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatisticsProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/QueryStatisticsProperties.Serialization.cs @@ -135,7 +135,7 @@ internal static QueryStatisticsProperties DeserializeQueryStatisticsProperties(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryMetricInterval.DeserializeQueryMetricInterval(item, options)); + array.Add(QueryMetricInterval.DeserializeQueryMetricInterval(item)); } intervals = array; continue; @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -185,21 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryId), out propertyOverride); if (Optional.IsDefined(QueryId) || hasPropertyOverride) { - builder.Append(" queryId:"); + builder.Append(" queryId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueryId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueryId}'''"); } else { - builder.AppendLine($" '{QueryId}'"); + builder.AppendLine($"'{QueryId}'"); } } } @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndTime), out propertyOverride); if (Optional.IsDefined(EndTime) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndTime}'''"); } else { - builder.AppendLine($" '{EndTime}'"); + builder.AppendLine($"'{EndTime}'"); } } } @@ -253,17 +253,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Intervals.Any() || hasPropertyOverride) { - builder.Append(" intervals:"); + builder.Append(" intervals: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Intervals) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " intervals: "); } builder.AppendLine(" ]"); } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReadScaleCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReadScaleCapability.Serialization.cs index 59da439e33a91..406124b892b4d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReadScaleCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReadScaleCapability.Serialization.cs @@ -134,49 +134,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxNumberOfReplicas), out propertyOverride); if (Optional.IsDefined(MaxNumberOfReplicas) || hasPropertyOverride) { - builder.Append(" maxNumberOfReplicas:"); + builder.Append(" maxNumberOfReplicas: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxNumberOfReplicas.Value}"); + builder.AppendLine($"{MaxNumberOfReplicas.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionErrorInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionErrorInfo.Serialization.cs index df48276979e60..e55912acadf31 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionErrorInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionErrorInfo.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorCode}'''"); } else { - builder.AppendLine($" '{ErrorCode}'"); + builder.AppendLine($"'{ErrorCode}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRetryable), out propertyOverride); if (Optional.IsDefined(IsRetryable) || hasPropertyOverride) { - builder.Append(" isRetryable:"); + builder.Append(" isRetryable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IsRetryable.Value.ToSerialString()}'"); + builder.AppendLine($"'{IsRetryable.Value.ToSerialString()}'"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImpactRecord.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImpactRecord.Serialization.cs index 13ff5b2051727..74892207e53f3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImpactRecord.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImpactRecord.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DimensionName), out propertyOverride); if (Optional.IsDefined(DimensionName) || hasPropertyOverride) { - builder.Append(" dimensionName:"); + builder.Append(" dimensionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DimensionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DimensionName}'''"); } else { - builder.AppendLine($" '{DimensionName}'"); + builder.AppendLine($"'{DimensionName}'"); } } } @@ -182,21 +182,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -204,42 +204,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AbsoluteValue), out propertyOverride); if (Optional.IsDefined(AbsoluteValue) || hasPropertyOverride) { - builder.Append(" absoluteValue:"); + builder.Append(" absoluteValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AbsoluteValue.Value.ToString()}'"); + builder.AppendLine($"'{AbsoluteValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeValueAbsolute), out propertyOverride); if (Optional.IsDefined(ChangeValueAbsolute) || hasPropertyOverride) { - builder.Append(" changeValueAbsolute:"); + builder.Append(" changeValueAbsolute: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ChangeValueAbsolute.Value.ToString()}'"); + builder.AppendLine($"'{ChangeValueAbsolute.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeValueRelative), out propertyOverride); if (Optional.IsDefined(ChangeValueRelative) || hasPropertyOverride) { - builder.Append(" changeValueRelative:"); + builder.Append(" changeValueRelative: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ChangeValueRelative.Value.ToString()}'"); + builder.AppendLine($"'{ChangeValueRelative.Value.ToString()}'"); } } @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImplementationInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImplementationInfo.Serialization.cs index 50443f662d626..ef7c93de45e3f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImplementationInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionImplementationInfo.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Method), out propertyOverride); if (Optional.IsDefined(Method) || hasPropertyOverride) { - builder.Append(" method:"); + builder.Append(" method: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Method.Value.ToSerialString()}'"); + builder.AppendLine($"'{Method.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Script), out propertyOverride); if (Optional.IsDefined(Script) || hasPropertyOverride) { - builder.Append(" script:"); + builder.Append(" script: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Script.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Script}'''"); } else { - builder.AppendLine($" '{Script}'"); + builder.AppendLine($"'{Script}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionMetricInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionMetricInfo.Serialization.cs index b8db29ac826d8..278f37ae2e976 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionMetricInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionMetricInfo.Serialization.cs @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricName), out propertyOverride); if (Optional.IsDefined(MetricName) || hasPropertyOverride) { - builder.Append(" metricName:"); + builder.Append(" metricName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MetricName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MetricName}'''"); } else { - builder.AppendLine($" '{MetricName}'"); + builder.AppendLine($"'{MetricName}'"); } } } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -200,21 +200,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -222,29 +222,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.Value.ToString()}'"); + builder.AppendLine($"'{Value.Value.ToString()}'"); } } @@ -252,12 +252,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -278,13 +281,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionStateInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionStateInfo.Serialization.cs index 0cb15f509c9cc..1dd62d1e0ca8b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionStateInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedActionStateInfo.Serialization.cs @@ -131,43 +131,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.ToString()}'"); + builder.AppendLine($"'{CurrentValue.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionInitiatedBy), out propertyOverride); if (Optional.IsDefined(ActionInitiatedBy) || hasPropertyOverride) { - builder.Append(" actionInitiatedBy:"); + builder.Append(" actionInitiatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionInitiatedBy.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActionInitiatedBy.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModified), out propertyOverride); if (Optional.IsDefined(LastModified) || hasPropertyOverride) { - builder.Append(" lastModified:"); + builder.Append(" lastModified: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModified.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdate.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdate.Serialization.cs index 472518d37a1de..1c5d29dfb5924 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdate.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdate.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -257,35 +257,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Op), out propertyOverride); if (Optional.IsDefined(Op) || hasPropertyOverride) { - builder.Append(" op:"); + builder.Append(" op: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Op.Value.ToSerialString()}'"); + builder.AppendLine($"'{Op.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schema), out propertyOverride); if (Optional.IsDefined(Schema) || hasPropertyOverride) { - builder.Append(" schema:"); + builder.Append(" schema: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Schema.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Schema}'''"); } else { - builder.AppendLine($" '{Schema}'"); + builder.AppendLine($"'{Schema}'"); } } } @@ -293,21 +293,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Table), out propertyOverride); if (Optional.IsDefined(Table) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Table.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Table}'''"); } else { - builder.AppendLine($" '{Table}'"); + builder.AppendLine($"'{Table}'"); } } } @@ -315,21 +315,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Column), out propertyOverride); if (Optional.IsDefined(Column) || hasPropertyOverride) { - builder.Append(" column:"); + builder.Append(" column: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Column.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Column}'''"); } else { - builder.AppendLine($" '{Column}'"); + builder.AppendLine($"'{Column}'"); } } } @@ -339,12 +339,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -365,13 +368,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdateList.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdateList.Serialization.cs index 9606bf9be7dc6..316c9511c53be 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdateList.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecommendedSensitivityLabelUpdateList.Serialization.cs @@ -88,7 +88,7 @@ internal static RecommendedSensitivityLabelUpdateList DeserializeRecommendedSens List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(RecommendedSensitivityLabelUpdate.DeserializeRecommendedSensitivityLabelUpdate(item, options)); + array.Add(RecommendedSensitivityLabelUpdate.DeserializeRecommendedSensitivityLabelUpdate(item)); } operations = array; continue; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableDatabaseListResult.Serialization.cs index 0a5e070c634b2..30911ed7397c7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableDatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static RecoverableDatabaseListResult DeserializeRecoverableDatabaseList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(RecoverableDatabaseData.DeserializeRecoverableDatabaseData(item, options)); + array.Add(RecoverableDatabaseData.DeserializeRecoverableDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableManagedDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableManagedDatabaseListResult.Serialization.cs index 29e9a126fc1b1..9b74613d07e28 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableManagedDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RecoverableManagedDatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static RecoverableManagedDatabaseListResult DeserializeRecoverableManag List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(RecoverableManagedDatabaseData.DeserializeRecoverableManagedDatabaseData(item, options)); + array.Add(RecoverableManagedDatabaseData.DeserializeRecoverableManagedDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RefreshExternalGovernanceStatusOperationResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RefreshExternalGovernanceStatusOperationResult.Serialization.cs index 6462bb80955b9..1a96595046aed 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RefreshExternalGovernanceStatusOperationResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RefreshExternalGovernanceStatusOperationResult.Serialization.cs @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -249,28 +249,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -279,35 +279,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestId), out propertyOverride); if (Optional.IsDefined(RequestId) || hasPropertyOverride) { - builder.Append(" requestId:"); + builder.Append(" requestId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestId.Value.ToString()}'"); + builder.AppendLine($"'{RequestId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestType), out propertyOverride); if (Optional.IsDefined(RequestType) || hasPropertyOverride) { - builder.Append(" requestType:"); + builder.Append(" requestType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestType}'''"); } else { - builder.AppendLine($" '{RequestType}'"); + builder.AppendLine($"'{RequestType}'"); } } } @@ -315,21 +315,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueuedTime), out propertyOverride); if (Optional.IsDefined(QueuedTime) || hasPropertyOverride) { - builder.Append(" queuedTime:"); + builder.Append(" queuedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QueuedTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QueuedTime}'''"); } else { - builder.AppendLine($" '{QueuedTime}'"); + builder.AppendLine($"'{QueuedTime}'"); } } } @@ -337,21 +337,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -359,21 +359,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -381,21 +381,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -405,12 +405,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -431,13 +434,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationLinkListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationLinkListResult.Serialization.cs index dce265b876d28..76c92ebfa27b1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationLinkListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationLinkListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ReplicationLinkListResult DeserializeReplicationLinkListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerDatabaseReplicationLinkData.DeserializeSqlServerDatabaseReplicationLinkData(item, options)); + array.Add(SqlServerDatabaseReplicationLinkData.DeserializeSqlServerDatabaseReplicationLinkData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ResourceWithWritableName.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ResourceWithWritableName.Serialization.cs index 31b41d9c7100e..fd3649c4240d6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ResourceWithWritableName.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ResourceWithWritableName.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,14 +156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseListResult.Serialization.cs index de942d04ed247..a190731151418 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static RestorableDroppedDatabaseListResult DeserializeRestorableDropped List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(RestorableDroppedDatabaseData.DeserializeRestorableDroppedDatabaseData(item, options)); + array.Add(RestorableDroppedDatabaseData.DeserializeRestorableDroppedDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedManagedDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedManagedDatabaseListResult.Serialization.cs index 6f3e2fcca2d97..0384c425bd2a2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedManagedDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedManagedDatabaseListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static RestorableDroppedManagedDatabaseListResult DeserializeRestorable List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(RestorableDroppedManagedDatabaseData.DeserializeRestorableDroppedManagedDatabaseData(item, options)); + array.Add(RestorableDroppedManagedDatabaseData.DeserializeRestorableDroppedManagedDatabaseData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorePointListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorePointListResult.Serialization.cs index e4484f2830cc6..df832e62e91f3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorePointListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorePointListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static RestorePointListResult DeserializeRestorePointListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerDatabaseRestorePointData.DeserializeSqlServerDatabaseRestorePointData(item, options)); + array.Add(SqlServerDatabaseRestorePointData.DeserializeSqlServerDatabaseRestorePointData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEvent.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEvent.Serialization.cs index 597cc572f07b3..54a266e31fc9a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEvent.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEvent.Serialization.cs @@ -244,7 +244,7 @@ internal static SecurityEvent DeserializeSecurityEvent(JsonElement element, Mode { continue; } - securityEventSqlInjectionAdditionalProperties = SecurityEventSqlInjectionAdditionalProperties.DeserializeSecurityEventSqlInjectionAdditionalProperties(property0.Value, options); + securityEventSqlInjectionAdditionalProperties = SecurityEventSqlInjectionAdditionalProperties.DeserializeSecurityEventSqlInjectionAdditionalProperties(property0.Value); continue; } } @@ -273,21 +273,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -295,28 +295,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -325,50 +325,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventOn), out propertyOverride); if (Optional.IsDefined(EventOn) || hasPropertyOverride) { - builder.Append(" eventTime:"); + builder.Append(" eventTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EventOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecurityEventType), out propertyOverride); if (Optional.IsDefined(SecurityEventType) || hasPropertyOverride) { - builder.Append(" securityEventType:"); + builder.Append(" securityEventType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SecurityEventType.Value.ToSerialString()}'"); + builder.AppendLine($"'{SecurityEventType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subscription), out propertyOverride); if (Optional.IsDefined(Subscription) || hasPropertyOverride) { - builder.Append(" subscription:"); + builder.Append(" subscription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subscription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subscription}'''"); } else { - builder.AppendLine($" '{Subscription}'"); + builder.AppendLine($"'{Subscription}'"); } } } @@ -376,21 +376,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Server), out propertyOverride); if (Optional.IsDefined(Server) || hasPropertyOverride) { - builder.Append(" server:"); + builder.Append(" server: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Server.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Server}'''"); } else { - builder.AppendLine($" '{Server}'"); + builder.AppendLine($"'{Server}'"); } } } @@ -398,21 +398,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Database), out propertyOverride); if (Optional.IsDefined(Database) || hasPropertyOverride) { - builder.Append(" database:"); + builder.Append(" database: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Database.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Database}'''"); } else { - builder.AppendLine($" '{Database}'"); + builder.AppendLine($"'{Database}'"); } } } @@ -420,35 +420,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientIP), out propertyOverride); if (Optional.IsDefined(ClientIP) || hasPropertyOverride) { - builder.Append(" clientIp:"); + builder.Append(" clientIp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ClientIP.ToString()}'"); + builder.AppendLine($"'{ClientIP.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationName), out propertyOverride); if (Optional.IsDefined(ApplicationName) || hasPropertyOverride) { - builder.Append(" applicationName:"); + builder.Append(" applicationName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApplicationName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApplicationName}'''"); } else { - builder.AppendLine($" '{ApplicationName}'"); + builder.AppendLine($"'{ApplicationName}'"); } } } @@ -456,21 +456,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalName), out propertyOverride); if (Optional.IsDefined(PrincipalName) || hasPropertyOverride) { - builder.Append(" principalName:"); + builder.Append(" principalName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrincipalName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrincipalName}'''"); } else { - builder.AppendLine($" '{PrincipalName}'"); + builder.AppendLine($"'{PrincipalName}'"); } } } @@ -478,14 +478,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecurityEventSqlInjectionAdditionalProperties), out propertyOverride); if (Optional.IsDefined(SecurityEventSqlInjectionAdditionalProperties) || hasPropertyOverride) { - builder.Append(" securityEventSqlInjectionAdditionalProperties:"); + builder.Append(" securityEventSqlInjectionAdditionalProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SecurityEventSqlInjectionAdditionalProperties, options, 4, false); + AppendChildObject(builder, SecurityEventSqlInjectionAdditionalProperties, options, 4, false, " securityEventSqlInjectionAdditionalProperties: "); } } @@ -494,12 +494,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -520,13 +523,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventCollection.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventCollection.Serialization.cs index 1a03a081ecf2b..41af5f9853b08 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventCollection.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventCollection.Serialization.cs @@ -97,7 +97,7 @@ internal static SecurityEventCollection DeserializeSecurityEventCollection(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SecurityEvent.DeserializeSecurityEvent(item, options)); + array.Add(SecurityEvent.DeserializeSecurityEvent(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventSqlInjectionAdditionalProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventSqlInjectionAdditionalProperties.Serialization.cs index 293ffa7d00b61..b21e982f5d5c1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventSqlInjectionAdditionalProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SecurityEventSqlInjectionAdditionalProperties.Serialization.cs @@ -186,21 +186,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThreatId), out propertyOverride); if (Optional.IsDefined(ThreatId) || hasPropertyOverride) { - builder.Append(" threatId:"); + builder.Append(" threatId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThreatId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThreatId}'''"); } else { - builder.AppendLine($" '{ThreatId}'"); + builder.AppendLine($"'{ThreatId}'"); } } } @@ -208,21 +208,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Statement), out propertyOverride); if (Optional.IsDefined(Statement) || hasPropertyOverride) { - builder.Append(" statement:"); + builder.Append(" statement: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Statement.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Statement}'''"); } else { - builder.AppendLine($" '{Statement}'"); + builder.AppendLine($"'{Statement}'"); } } } @@ -230,77 +230,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatementHighlightOffset), out propertyOverride); if (Optional.IsDefined(StatementHighlightOffset) || hasPropertyOverride) { - builder.Append(" statementHighlightOffset:"); + builder.Append(" statementHighlightOffset: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StatementHighlightOffset.Value}"); + builder.AppendLine($"{StatementHighlightOffset.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatementHighlightLength), out propertyOverride); if (Optional.IsDefined(StatementHighlightLength) || hasPropertyOverride) { - builder.Append(" statementHighlightLength:"); + builder.Append(" statementHighlightLength: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StatementHighlightLength.Value}"); + builder.AppendLine($"{StatementHighlightLength.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -309,12 +309,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -335,13 +338,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelListResult.Serialization.cs index 79da84e53be5d..88ff09b745d6f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SensitivityLabelListResult DeserializeSensitivityLabelListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SensitivityLabelData.DeserializeSensitivityLabelData(item, options)); + array.Add(SensitivityLabelData.DeserializeSensitivityLabelData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdate.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdate.Serialization.cs index 4000563642ab6..eb0c14e01ee24 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdate.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdate.Serialization.cs @@ -192,7 +192,7 @@ internal static SensitivityLabelUpdate DeserializeSensitivityLabelUpdate(JsonEle { continue; } - sensitivityLabel = SensitivityLabelData.DeserializeSensitivityLabelData(property0.Value, options); + sensitivityLabel = SensitivityLabelData.DeserializeSensitivityLabelData(property0.Value); continue; } } @@ -221,21 +221,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -243,28 +243,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -273,35 +273,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Op), out propertyOverride); if (Optional.IsDefined(Op) || hasPropertyOverride) { - builder.Append(" op:"); + builder.Append(" op: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Op.Value.ToSerialString()}'"); + builder.AppendLine($"'{Op.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schema), out propertyOverride); if (Optional.IsDefined(Schema) || hasPropertyOverride) { - builder.Append(" schema:"); + builder.Append(" schema: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Schema.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Schema}'''"); } else { - builder.AppendLine($" '{Schema}'"); + builder.AppendLine($"'{Schema}'"); } } } @@ -309,21 +309,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Table), out propertyOverride); if (Optional.IsDefined(Table) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Table.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Table}'''"); } else { - builder.AppendLine($" '{Table}'"); + builder.AppendLine($"'{Table}'"); } } } @@ -331,21 +331,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Column), out propertyOverride); if (Optional.IsDefined(Column) || hasPropertyOverride) { - builder.Append(" column:"); + builder.Append(" column: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Column.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Column}'''"); } else { - builder.AppendLine($" '{Column}'"); + builder.AppendLine($"'{Column}'"); } } } @@ -353,14 +353,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SensitivityLabel), out propertyOverride); if (Optional.IsDefined(SensitivityLabel) || hasPropertyOverride) { - builder.Append(" sensitivityLabel:"); + builder.Append(" sensitivityLabel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SensitivityLabel, options, 4, false); + AppendChildObject(builder, SensitivityLabel, options, 4, false, " sensitivityLabel: "); } } @@ -369,12 +369,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -395,13 +398,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdateList.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdateList.Serialization.cs index e259d75da1b8b..174293c6f648d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdateList.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SensitivityLabelUpdateList.Serialization.cs @@ -88,7 +88,7 @@ internal static SensitivityLabelUpdateList DeserializeSensitivityLabelUpdateList List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SensitivityLabelUpdate.DeserializeSensitivityLabelUpdate(item, options)); + array.Add(SensitivityLabelUpdate.DeserializeSensitivityLabelUpdate(item)); } operations = array; continue; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerBlobAuditingPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerBlobAuditingPolicyListResult.Serialization.cs index ef779cf2d98ad..26aa3ed87f387 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerBlobAuditingPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerBlobAuditingPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerBlobAuditingPolicyListResult DeserializeServerBlobAuditing List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerBlobAuditingPolicyData.DeserializeSqlServerBlobAuditingPolicyData(item, options)); + array.Add(SqlServerBlobAuditingPolicyData.DeserializeSqlServerBlobAuditingPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerCommunicationLinkListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerCommunicationLinkListResult.Serialization.cs index 579796afbbf01..aab91be44147c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerCommunicationLinkListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerCommunicationLinkListResult.Serialization.cs @@ -92,7 +92,7 @@ internal static ServerCommunicationLinkListResult DeserializeServerCommunication List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerCommunicationLinkData.DeserializeSqlServerCommunicationLinkData(item, options)); + array.Add(SqlServerCommunicationLinkData.DeserializeSqlServerCommunicationLinkData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConfigurationOptionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConfigurationOptionListResult.Serialization.cs index bfecd5b1f43bb..e99f8ef89c3d5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConfigurationOptionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConfigurationOptionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerConfigurationOptionListResult DeserializeServerConfigurati List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceServerConfigurationOptionData.DeserializeManagedInstanceServerConfigurationOptionData(item, options)); + array.Add(ManagedInstanceServerConfigurationOptionData.DeserializeManagedInstanceServerConfigurationOptionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConnectionPolicyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConnectionPolicyListResult.Serialization.cs index 0c05caf9da210..10119abd33aee 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConnectionPolicyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerConnectionPolicyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerConnectionPolicyListResult DeserializeServerConnectionPoli List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerConnectionPolicyData.DeserializeSqlServerConnectionPolicyData(item, options)); + array.Add(SqlServerConnectionPolicyData.DeserializeSqlServerConnectionPolicyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDevOpsAuditSettingsListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDevOpsAuditSettingsListResult.Serialization.cs index d87cc7def674d..db2a4a014dcfc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDevOpsAuditSettingsListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDevOpsAuditSettingsListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerDevOpsAuditSettingsListResult DeserializeServerDevOpsAudit List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerDevOpsAuditingSettingData.DeserializeSqlServerDevOpsAuditingSettingData(item, options)); + array.Add(SqlServerDevOpsAuditingSettingData.DeserializeSqlServerDevOpsAuditingSettingData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDnsAliasListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDnsAliasListResult.Serialization.cs index 8b7ed5e4fc76c..296cd2e209b4e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDnsAliasListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerDnsAliasListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerDnsAliasListResult DeserializeServerDnsAliasListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerDnsAliasData.DeserializeSqlServerDnsAliasData(item, options)); + array.Add(SqlServerDnsAliasData.DeserializeSqlServerDnsAliasData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerExternalAdministrator.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerExternalAdministrator.Serialization.cs index 62f282757e289..d6acaa248ceba 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerExternalAdministrator.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerExternalAdministrator.Serialization.cs @@ -179,49 +179,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) { - builder.Append(" administratorType:"); + builder.Append(" administratorType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AdministratorType.Value.ToString()}'"); + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalType), out propertyOverride); if (Optional.IsDefined(PrincipalType) || hasPropertyOverride) { - builder.Append(" principalType:"); + builder.Append(" principalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalType.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Login.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Login}'''"); } else { - builder.AppendLine($" '{Login}'"); + builder.AppendLine($"'{Login}'"); } } } @@ -229,43 +229,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); if (Optional.IsDefined(Sid) || hasPropertyOverride) { - builder.Append(" sid:"); + builder.Append(" sid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Sid.Value.ToString()}'"); + builder.AppendLine($"'{Sid.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureADOnlyAuthenticationEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureADOnlyAuthenticationEnabled) || hasPropertyOverride) { - builder.Append(" azureADOnlyAuthentication:"); + builder.Append(" azureADOnlyAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureADOnlyAuthenticationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -273,12 +273,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -299,13 +302,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerKeyListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerKeyListResult.Serialization.cs index 7e6f0d4b7dd74..925eff926853a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerKeyListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerKeyListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerKeyListResult DeserializeServerKeyListResult(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerKeyData.DeserializeSqlServerKeyData(item, options)); + array.Add(SqlServerKeyData.DeserializeSqlServerKeyData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerListResult.Serialization.cs index 6da052d20df7a..d50f1d243f380 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerListResult DeserializeServerListResult(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerData.DeserializeSqlServerData(item, options)); + array.Add(SqlServerData.DeserializeSqlServerData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationData.Serialization.cs index 6b9a02f3c6dd5..b9cebd21e10d7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationData.Serialization.cs @@ -332,21 +332,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -354,28 +354,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -384,21 +384,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -406,21 +406,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationFriendlyName), out propertyOverride); if (Optional.IsDefined(OperationFriendlyName) || hasPropertyOverride) { - builder.Append(" operationFriendlyName:"); + builder.Append(" operationFriendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationFriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationFriendlyName}'''"); } else { - builder.AppendLine($" '{OperationFriendlyName}'"); + builder.AppendLine($"'{OperationFriendlyName}'"); } } } @@ -428,35 +428,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -464,64 +464,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorCode), out propertyOverride); if (Optional.IsDefined(ErrorCode) || hasPropertyOverride) { - builder.Append(" errorCode:"); + builder.Append(" errorCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorCode.Value}"); + builder.AppendLine($"{ErrorCode.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDescription), out propertyOverride); if (Optional.IsDefined(ErrorDescription) || hasPropertyOverride) { - builder.Append(" errorDescription:"); + builder.Append(" errorDescription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorDescription}'''"); } else { - builder.AppendLine($" '{ErrorDescription}'"); + builder.AppendLine($"'{ErrorDescription}'"); } } } @@ -529,65 +529,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorSeverity), out propertyOverride); if (Optional.IsDefined(ErrorSeverity) || hasPropertyOverride) { - builder.Append(" errorSeverity:"); + builder.Append(" errorSeverity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ErrorSeverity.Value}"); + builder.AppendLine($"{ErrorSeverity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUserError), out propertyOverride); if (Optional.IsDefined(IsUserError) || hasPropertyOverride) { - builder.Append(" isUserError:"); + builder.Append(" isUserError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUserError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EstimatedCompleteOn), out propertyOverride); if (Optional.IsDefined(EstimatedCompleteOn) || hasPropertyOverride) { - builder.Append(" estimatedCompletionTime:"); + builder.Append(" estimatedCompletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EstimatedCompleteOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -595,15 +595,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsCancellable), out propertyOverride); if (Optional.IsDefined(IsCancellable) || hasPropertyOverride) { - builder.Append(" isCancellable:"); + builder.Append(" isCancellable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsCancellable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -612,12 +612,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -638,13 +641,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationListResult.Serialization.cs index 497f0858411c7..b2cfb1f087426 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerOperationListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static ServerOperationListResult DeserializeServerOperationListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ServerOperationData.DeserializeServerOperationData(item, options)); + array.Add(ServerOperationData.DeserializeServerOperationData(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerPrivateEndpointConnectionProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerPrivateEndpointConnectionProperties.Serialization.cs index fb4648b46b5fb..289b6a736ee06 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerPrivateEndpointConnectionProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerPrivateEndpointConnectionProperties.Serialization.cs @@ -130,7 +130,7 @@ internal static ServerPrivateEndpointConnectionProperties DeserializeServerPriva { continue; } - privateLinkServiceConnectionState = SqlPrivateLinkServiceConnectionStateProperty.DeserializeSqlPrivateLinkServiceConnectionStateProperty(property.Value, options); + privateLinkServiceConnectionState = SqlPrivateLinkServiceConnectionStateProperty.DeserializeSqlPrivateLinkServiceConnectionStateProperty(property.Value); continue; } if (property.NameEquals("provisioningState"u8)) @@ -165,14 +165,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 2, false); + AppendChildObject(builder, PrivateEndpoint, options, 2, false, " privateEndpoint: "); } } @@ -181,14 +181,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GroupIds.Any() || hasPropertyOverride) { - builder.Append(" groupIds:"); + builder.Append(" groupIds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GroupIds) { if (item == null) @@ -214,28 +214,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 2, false); + AppendChildObject(builder, ConnectionState, options, 2, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -243,12 +243,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -269,13 +272,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs index 01b644dcc4d28..43e695349c541 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerTrustCertificatesListResult DeserializeServerTrustCertific List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ServerTrustCertificateData.DeserializeServerTrustCertificateData(item, options)); + array.Add(ServerTrustCertificateData.DeserializeServerTrustCertificateData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupListResult.Serialization.cs index 4881c03374212..1cb5b7a058e97 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerTrustGroupListResult DeserializeServerTrustGroupListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerTrustGroupData.DeserializeSqlServerTrustGroupData(item, options)); + array.Add(SqlServerTrustGroupData.DeserializeSqlServerTrustGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupServerInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupServerInfo.Serialization.cs index 9cbf2aa79f47e..5dd241b75df01 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupServerInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustGroupServerInfo.Serialization.cs @@ -101,14 +101,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerId), out propertyOverride); if (Optional.IsDefined(ServerId) || hasPropertyOverride) { - builder.Append(" serverId:"); + builder.Append(" serverId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerId.ToString()}'"); + builder.AppendLine($"'{ServerId.ToString()}'"); } } @@ -116,12 +116,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -142,13 +145,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerUsageListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerUsageListResult.Serialization.cs index b2b94313f069f..e8764d2f31d79 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerUsageListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerUsageListResult.Serialization.cs @@ -84,7 +84,7 @@ internal static ServerUsageListResult DeserializeServerUsageListResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerUsage.DeserializeSqlServerUsage(item, options)); + array.Add(SqlServerUsage.DeserializeSqlServerUsage(item)); } value = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerVulnerabilityAssessmentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerVulnerabilityAssessmentListResult.Serialization.cs index 0ddd7a00f0a57..892083983928a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerVulnerabilityAssessmentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerVulnerabilityAssessmentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static ServerVulnerabilityAssessmentListResult DeserializeServerVulnera List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerVulnerabilityAssessmentData.DeserializeSqlServerVulnerabilityAssessmentData(item, options)); + array.Add(SqlServerVulnerabilityAssessmentData.DeserializeSqlServerVulnerabilityAssessmentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveCapability.Serialization.cs index 4de7d580799f0..6f388e3d6a489 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveCapability.Serialization.cs @@ -198,7 +198,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item, options)); + array.Add(MaxSizeRangeCapability.DeserializeMaxSizeRangeCapability(item)); } supportedMaxSizes = array; continue; @@ -209,7 +209,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability { continue; } - performanceLevel = PerformanceLevelCapability.DeserializePerformanceLevelCapability(property.Value, options); + performanceLevel = PerformanceLevelCapability.DeserializePerformanceLevelCapability(property.Value); continue; } if (property.NameEquals("sku"u8)) @@ -218,7 +218,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("supportedLicenseTypes"u8)) @@ -230,7 +230,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item, options)); + array.Add(LicenseTypeCapability.DeserializeLicenseTypeCapability(item)); } supportedLicenseTypes = array; continue; @@ -241,7 +241,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability { continue; } - includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value, options); + includedMaxSize = MaxSizeCapability.DeserializeMaxSizeCapability(property.Value); continue; } if (property.NameEquals("zoneRedundant"u8)) @@ -259,7 +259,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability { continue; } - supportedAutoPauseDelay = AutoPauseDelayTimeRange.DeserializeAutoPauseDelayTimeRange(property.Value, options); + supportedAutoPauseDelay = AutoPauseDelayTimeRange.DeserializeAutoPauseDelayTimeRange(property.Value); continue; } if (property.NameEquals("supportedMinCapacities"u8)) @@ -271,7 +271,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MinCapacityCapability.DeserializeMinCapacityCapability(item, options)); + array.Add(MinCapacityCapability.DeserializeMinCapacityCapability(item)); } supportedMinCapacities = array; continue; @@ -290,7 +290,7 @@ internal static ServiceObjectiveCapability DeserializeServiceObjectiveCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MaintenanceConfigurationCapability.DeserializeMaintenanceConfigurationCapability(item, options)); + array.Add(MaintenanceConfigurationCapability.DeserializeMaintenanceConfigurationCapability(item)); } supportedMaintenanceConfigurations = array; continue; @@ -332,21 +332,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -354,14 +354,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.Value.ToString()}'"); + builder.AppendLine($"'{Id.Value.ToString()}'"); } } @@ -370,17 +370,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMaxSizes.Any() || hasPropertyOverride) { - builder.Append(" supportedMaxSizes:"); + builder.Append(" supportedMaxSizes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMaxSizes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMaxSizes: "); } builder.AppendLine(" ]"); } @@ -390,28 +390,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PerformanceLevel), out propertyOverride); if (Optional.IsDefined(PerformanceLevel) || hasPropertyOverride) { - builder.Append(" performanceLevel:"); + builder.Append(" performanceLevel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PerformanceLevel, options, 2, false); + AppendChildObject(builder, PerformanceLevel, options, 2, false, " performanceLevel: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } @@ -420,17 +420,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedLicenseTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedLicenseTypes:"); + builder.Append(" supportedLicenseTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedLicenseTypes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedLicenseTypes: "); } builder.AppendLine(" ]"); } @@ -440,43 +440,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludedMaxSize), out propertyOverride); if (Optional.IsDefined(IncludedMaxSize) || hasPropertyOverride) { - builder.Append(" includedMaxSize:"); + builder.Append(" includedMaxSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IncludedMaxSize, options, 2, false); + AppendChildObject(builder, IncludedMaxSize, options, 2, false, " includedMaxSize: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedAutoPauseDelay), out propertyOverride); if (Optional.IsDefined(SupportedAutoPauseDelay) || hasPropertyOverride) { - builder.Append(" supportedAutoPauseDelay:"); + builder.Append(" supportedAutoPauseDelay: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SupportedAutoPauseDelay, options, 2, false); + AppendChildObject(builder, SupportedAutoPauseDelay, options, 2, false, " supportedAutoPauseDelay: "); } } @@ -485,17 +485,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMinCapacities.Any() || hasPropertyOverride) { - builder.Append(" supportedMinCapacities:"); + builder.Append(" supportedMinCapacities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMinCapacities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMinCapacities: "); } builder.AppendLine(" ]"); } @@ -505,21 +505,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ComputeModel), out propertyOverride); if (Optional.IsDefined(ComputeModel) || hasPropertyOverride) { - builder.Append(" computeModel:"); + builder.Append(" computeModel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ComputeModel.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ComputeModel}'''"); } else { - builder.AppendLine($" '{ComputeModel}'"); + builder.AppendLine($"'{ComputeModel}'"); } } } @@ -529,17 +529,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedMaintenanceConfigurations.Any() || hasPropertyOverride) { - builder.Append(" supportedMaintenanceConfigurations:"); + builder.Append(" supportedMaintenanceConfigurations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedMaintenanceConfigurations) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedMaintenanceConfigurations: "); } builder.AppendLine(" ]"); } @@ -549,35 +549,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -586,12 +586,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -612,13 +615,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveListResult.Serialization.cs index fdaeba4d5193a..fb126ec467dbf 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServiceObjectiveListResult.Serialization.cs @@ -85,7 +85,7 @@ internal static ServiceObjectiveListResult DeserializeServiceObjectiveListResult List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ServiceObjectiveData.DeserializeServiceObjectiveData(item, options)); + array.Add(ServiceObjectiveData.DeserializeServiceObjectiveData(item)); } value = array; continue; @@ -115,17 +115,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,12 +136,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -162,13 +165,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseExtension.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseExtension.Serialization.cs index cf906c380e986..0a16433b3bdaa 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseExtension.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseExtension.Serialization.cs @@ -213,21 +213,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -235,28 +235,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -265,49 +265,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationMode), out propertyOverride); if (Optional.IsDefined(OperationMode) || hasPropertyOverride) { - builder.Append(" operationMode:"); + builder.Append(" operationMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OperationMode.Value.ToString()}'"); + builder.AppendLine($"'{OperationMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageKeyType), out propertyOverride); if (Optional.IsDefined(StorageKeyType) || hasPropertyOverride) { - builder.Append(" storageKeyType:"); + builder.Append(" storageKeyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageKeyType.Value.ToString()}'"); + builder.AppendLine($"'{StorageKeyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageKey), out propertyOverride); if (Optional.IsDefined(StorageKey) || hasPropertyOverride) { - builder.Append(" storageKey:"); + builder.Append(" storageKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageKey}'''"); } else { - builder.AppendLine($" '{StorageKey}'"); + builder.AppendLine($"'{StorageKey}'"); } } } @@ -315,14 +315,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageUri), out propertyOverride); if (Optional.IsDefined(StorageUri) || hasPropertyOverride) { - builder.Append(" storageUri:"); + builder.Append(" storageUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageUri.AbsoluteUri}'"); + builder.AppendLine($"'{StorageUri.AbsoluteUri}'"); } } @@ -331,12 +331,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -357,13 +360,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseKey.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseKey.Serialization.cs index 600d442439e07..cc6e19c5d2a68 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseKey.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseKey.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -167,36 +167,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subregion), out propertyOverride); if (Optional.IsDefined(Subregion) || hasPropertyOverride) { - builder.Append(" subregion:"); + builder.Append(" subregion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subregion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subregion}'''"); } else { - builder.AppendLine($" '{Subregion}'"); + builder.AppendLine($"'{Subregion}'"); } } } @@ -205,12 +205,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -231,13 +234,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabasePatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabasePatch.Serialization.cs index 8efd71a0608fb..1501128dada70 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabasePatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabasePatch.Serialization.cs @@ -383,7 +383,7 @@ internal static SqlDatabasePatch DeserializeSqlDatabasePatch(JsonElement element { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("identity"u8)) @@ -392,7 +392,7 @@ internal static SqlDatabasePatch DeserializeSqlDatabasePatch(JsonElement element { continue; } - identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value, options); + identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -655,7 +655,7 @@ internal static SqlDatabasePatch DeserializeSqlDatabasePatch(JsonElement element { continue; } - currentSku = SqlSku.DeserializeSqlSku(property0.Value, options); + currentSku = SqlSku.DeserializeSqlSku(property0.Value); continue; } if (property0.NameEquals("autoPauseDelay"u8)) @@ -757,7 +757,7 @@ internal static SqlDatabasePatch DeserializeSqlDatabasePatch(JsonElement element Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value, options)); + dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value)); } keys = dictionary; continue; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlLocationCapabilities.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlLocationCapabilities.Serialization.cs index 536a26b111bb3..6ae100a9b0865 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlLocationCapabilities.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlLocationCapabilities.Serialization.cs @@ -125,7 +125,7 @@ internal static SqlLocationCapabilities DeserializeSqlLocationCapabilities(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerVersionCapability.DeserializeSqlServerVersionCapability(item, options)); + array.Add(SqlServerVersionCapability.DeserializeSqlServerVersionCapability(item)); } supportedServerVersions = array; continue; @@ -139,7 +139,7 @@ internal static SqlLocationCapabilities DeserializeSqlLocationCapabilities(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceVersionCapability.DeserializeManagedInstanceVersionCapability(item, options)); + array.Add(ManagedInstanceVersionCapability.DeserializeManagedInstanceVersionCapability(item)); } supportedManagedInstanceVersions = array; continue; @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,17 +205,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedServerVersions.Any() || hasPropertyOverride) { - builder.Append(" supportedServerVersions:"); + builder.Append(" supportedServerVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedServerVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedServerVersions: "); } builder.AppendLine(" ]"); } @@ -227,17 +227,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedManagedInstanceVersions.Any() || hasPropertyOverride) { - builder.Append(" supportedManagedInstanceVersions:"); + builder.Append(" supportedManagedInstanceVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedManagedInstanceVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedManagedInstanceVersions: "); } builder.AppendLine(" ]"); } @@ -247,35 +247,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -284,12 +284,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -310,13 +313,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetric.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetric.Serialization.cs index 6aa4593311105..8437fa65ef6e0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetric.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetric.Serialization.cs @@ -150,7 +150,7 @@ internal static SqlMetric DeserializeSqlMetric(JsonElement element, ModelReaderW { continue; } - name = SqlMetricName.DeserializeSqlMetricName(property.Value, options); + name = SqlMetricName.DeserializeSqlMetricName(property.Value); continue; } if (property.NameEquals("metricValues"u8)) @@ -162,7 +162,7 @@ internal static SqlMetric DeserializeSqlMetric(JsonElement element, ModelReaderW List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlMetricValue.DeserializeSqlMetricValue(item, options)); + array.Add(SqlMetricValue.DeserializeSqlMetricValue(item)); } metricValues = array; continue; @@ -190,65 +190,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Name, options, 2, false); + AppendChildObject(builder, Name, options, 2, false, " name: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -256,14 +256,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -272,17 +272,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MetricValues.Any() || hasPropertyOverride) { - builder.Append(" metricValues:"); + builder.Append(" metricValues: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MetricValues) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " metricValues: "); } builder.AppendLine(" ]"); } @@ -293,12 +293,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -319,13 +322,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricAvailability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricAvailability.Serialization.cs index 9e74a065e6b97..a36ee011b1a34 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricAvailability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricAvailability.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Retention), out propertyOverride); if (Optional.IsDefined(Retention) || hasPropertyOverride) { - builder.Append(" retention:"); + builder.Append(" retention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Retention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Retention}'''"); } else { - builder.AppendLine($" '{Retention}'"); + builder.AppendLine($"'{Retention}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricDefinition.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricDefinition.Serialization.cs index 1fc7b3bacc3b1..acff46db1d26e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricDefinition.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricDefinition.Serialization.cs @@ -112,7 +112,7 @@ internal static SqlMetricDefinition DeserializeSqlMetricDefinition(JsonElement e { continue; } - name = SqlMetricName.DeserializeSqlMetricName(property.Value, options); + name = SqlMetricName.DeserializeSqlMetricName(property.Value); continue; } if (property.NameEquals("primaryAggregationType"u8)) @@ -147,7 +147,7 @@ internal static SqlMetricDefinition DeserializeSqlMetricDefinition(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlMetricAvailability.DeserializeSqlMetricAvailability(item, options)); + array.Add(SqlMetricAvailability.DeserializeSqlMetricAvailability(item)); } metricAvailabilities = array; continue; @@ -175,49 +175,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Name, options, 2, false); + AppendChildObject(builder, Name, options, 2, false, " name: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryAggregationType), out propertyOverride); if (Optional.IsDefined(PrimaryAggregationType) || hasPropertyOverride) { - builder.Append(" primaryAggregationType:"); + builder.Append(" primaryAggregationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryAggregationType.Value.ToString()}'"); + builder.AppendLine($"'{PrimaryAggregationType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceUriString), out propertyOverride); if (Optional.IsDefined(ResourceUriString) || hasPropertyOverride) { - builder.Append(" resourceUri:"); + builder.Append(" resourceUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceUriString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceUriString}'''"); } else { - builder.AppendLine($" '{ResourceUriString}'"); + builder.AppendLine($"'{ResourceUriString}'"); } } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToString()}'"); + builder.AppendLine($"'{Unit.Value.ToString()}'"); } } @@ -241,17 +241,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MetricAvailabilities.Any() || hasPropertyOverride) { - builder.Append(" metricAvailabilities:"); + builder.Append(" metricAvailabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MetricAvailabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " metricAvailabilities: "); } builder.AppendLine(" ]"); } @@ -262,12 +262,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -288,13 +291,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricListResult.Serialization.cs index 5165f3aa2db59..485a04f713460 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricListResult.Serialization.cs @@ -84,7 +84,7 @@ internal static SqlMetricListResult DeserializeSqlMetricListResult(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlMetric.DeserializeSqlMetric(item, options)); + array.Add(SqlMetric.DeserializeSqlMetric(item)); } value = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricName.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricName.Serialization.cs index 8938fca95b04f..1063c2374ca12 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricName.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricName.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalizedValue), out propertyOverride); if (Optional.IsDefined(LocalizedValue) || hasPropertyOverride) { - builder.Append(" localizedValue:"); + builder.Append(" localizedValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalizedValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalizedValue}'''"); } else { - builder.AppendLine($" '{LocalizedValue}'"); + builder.AppendLine($"'{LocalizedValue}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricValue.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricValue.Serialization.cs index 4d2f5480d8eb8..e2b5bd643903f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricValue.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlMetricValue.Serialization.cs @@ -183,85 +183,85 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Average), out propertyOverride); if (Optional.IsDefined(Average) || hasPropertyOverride) { - builder.Append(" average:"); + builder.Append(" average: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Average.Value.ToString()}'"); + builder.AppendLine($"'{Average.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Maximum), out propertyOverride); if (Optional.IsDefined(Maximum) || hasPropertyOverride) { - builder.Append(" maximum:"); + builder.Append(" maximum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Maximum.Value.ToString()}'"); + builder.AppendLine($"'{Maximum.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Minimum), out propertyOverride); if (Optional.IsDefined(Minimum) || hasPropertyOverride) { - builder.Append(" minimum:"); + builder.Append(" minimum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Minimum.Value.ToString()}'"); + builder.AppendLine($"'{Minimum.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Total), out propertyOverride); if (Optional.IsDefined(Total) || hasPropertyOverride) { - builder.Append(" total:"); + builder.Append(" total: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Total.Value.ToString()}'"); + builder.AppendLine($"'{Total.Value.ToString()}'"); } } @@ -269,12 +269,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -295,13 +298,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlNameAvailabilityResponse.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlNameAvailabilityResponse.Serialization.cs index d3f0a88655b9f..f94584b29e9eb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlNameAvailabilityResponse.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlNameAvailabilityResponse.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -167,50 +167,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAvailable), out propertyOverride); if (Optional.IsDefined(IsAvailable) || hasPropertyOverride) { - builder.Append(" available:"); + builder.Append(" available: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToSerialString()}'"); + builder.AppendLine($"'{Reason.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -219,12 +219,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -245,13 +248,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpoint.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpoint.Serialization.cs index 115eb7b6ace2e..d219f5786f4bd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpoint.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpoint.Serialization.cs @@ -102,7 +102,7 @@ internal static SqlOutboundEnvironmentEndpoint DeserializeSqlOutboundEnvironment List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceEndpointDependency.DeserializeManagedInstanceEndpointDependency(item, options)); + array.Add(ManagedInstanceEndpointDependency.DeserializeManagedInstanceEndpointDependency(item)); } endpoints = array; continue; @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Endpoints.Any() || hasPropertyOverride) { - builder.Append(" endpoints:"); + builder.Append(" endpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Endpoints) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " endpoints: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpointCollection.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpointCollection.Serialization.cs index 7352f717f4f0f..d06ce51244b05 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpointCollection.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlOutboundEnvironmentEndpointCollection.Serialization.cs @@ -97,7 +97,7 @@ internal static SqlOutboundEnvironmentEndpointCollection DeserializeSqlOutboundE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlOutboundEnvironmentEndpoint.DeserializeSqlOutboundEnvironmentEndpoint(item, options)); + array.Add(SqlOutboundEnvironmentEndpoint.DeserializeSqlOutboundEnvironmentEndpoint(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateEndpointConnectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateEndpointConnectionListResult.Serialization.cs index b0e222dad6db4..ea7b066305b29 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateEndpointConnectionListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SqlPrivateEndpointConnectionListResult DeserializeSqlPrivateEndp List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlPrivateEndpointConnectionData.DeserializeSqlPrivateEndpointConnectionData(item, options)); + array.Add(SqlPrivateEndpointConnectionData.DeserializeSqlPrivateEndpointConnectionData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceListResult.Serialization.cs index 9fdc9ed9fb80a..3be7db02fe3ca 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SqlPrivateLinkResourceListResult DeserializeSqlPrivateLinkResour List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlPrivateLinkResourceData.DeserializeSqlPrivateLinkResourceData(item, options)); + array.Add(SqlPrivateLinkResourceData.DeserializeSqlPrivateLinkResourceData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceProperties.Serialization.cs index 3d8d6675ee169..0404a2c4719b6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkResourceProperties.Serialization.cs @@ -155,21 +155,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -179,14 +179,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -214,14 +214,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -248,12 +248,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -274,13 +277,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkServiceConnectionStateProperty.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkServiceConnectionStateProperty.Serialization.cs index 8fceb649f4f12..93d1b84370f13 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkServiceConnectionStateProperty.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlPrivateLinkServiceConnectionStateProperty.Serialization.cs @@ -124,35 +124,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.ToString()}'"); + builder.AppendLine($"'{Status.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -160,14 +160,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionsRequired.Value.ToString()}'"); + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlScheduleItem.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlScheduleItem.Serialization.cs index fb5153ac12f73..4cb39d887f5e0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlScheduleItem.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlScheduleItem.Serialization.cs @@ -125,35 +125,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartDay), out propertyOverride); if (Optional.IsDefined(StartDay) || hasPropertyOverride) { - builder.Append(" startDay:"); + builder.Append(" startDay: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StartDay.ToString()}'"); + builder.AppendLine($"'{StartDay.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -161,35 +161,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StopDay), out propertyOverride); if (Optional.IsDefined(StopDay) || hasPropertyOverride) { - builder.Append(" stopDay:"); + builder.Append(" stopDay: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StopDay.ToString()}'"); + builder.AppendLine($"'{StopDay.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StopTime), out propertyOverride); if (Optional.IsDefined(StopTime) || hasPropertyOverride) { - builder.Append(" stopTime:"); + builder.Append(" stopTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StopTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StopTime}'''"); } else { - builder.AppendLine($" '{StopTime}'"); + builder.AppendLine($"'{StopTime}'"); } } } @@ -198,12 +198,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -224,13 +227,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerJobSchedule.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerJobSchedule.Serialization.cs index 68ce4af1d9b41..c05b59b3e15b4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerJobSchedule.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerJobSchedule.Serialization.cs @@ -168,60 +168,60 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Interval), out propertyOverride); if (Optional.IsDefined(Interval) || hasPropertyOverride) { - builder.Append(" interval:"); + builder.Append(" interval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Interval.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } @@ -229,12 +229,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -255,13 +258,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPatch.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPatch.Serialization.cs index 950a94ca91490..8914a6f113b54 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPatch.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPatch.Serialization.cs @@ -259,7 +259,7 @@ internal static SqlServerPatch DeserializeSqlServerPatch(JsonElement element, Mo List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SqlServerPrivateEndpointConnection.DeserializeSqlServerPrivateEndpointConnection(item, options)); + array.Add(SqlServerPrivateEndpointConnection.DeserializeSqlServerPrivateEndpointConnection(item)); } privateEndpointConnections = array; continue; @@ -324,7 +324,7 @@ internal static SqlServerPatch DeserializeSqlServerPatch(JsonElement element, Mo { continue; } - administrators = ServerExternalAdministrator.DeserializeServerExternalAdministrator(property0.Value, options); + administrators = ServerExternalAdministrator.DeserializeServerExternalAdministrator(property0.Value); continue; } if (property0.NameEquals("restrictOutboundNetworkAccess"u8)) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPrivateEndpointConnection.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPrivateEndpointConnection.Serialization.cs index 3fdc7ce647327..e99bef6026b7a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPrivateEndpointConnection.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerPrivateEndpointConnection.Serialization.cs @@ -97,7 +97,7 @@ internal static SqlServerPrivateEndpointConnection DeserializeSqlServerPrivateEn { continue; } - properties = ServerPrivateEndpointConnectionProperties.DeserializeServerPrivateEndpointConnectionProperties(property.Value, options); + properties = ServerPrivateEndpointConnectionProperties.DeserializeServerPrivateEndpointConnectionProperties(property.Value); continue; } if (options.Format != "W") @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerUsage.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerUsage.Serialization.cs index ffa9980734a04..b78ea2207bcb6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerUsage.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerUsage.Serialization.cs @@ -182,21 +182,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -226,21 +226,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -248,49 +248,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.Value.ToString()}'"); + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -298,15 +298,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextResetOn), out propertyOverride); if (Optional.IsDefined(NextResetOn) || hasPropertyOverride) { - builder.Append(" nextResetTime:"); + builder.Append(" nextResetTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextResetOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -314,12 +314,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -340,13 +343,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerVersionCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerVersionCapability.Serialization.cs index d1eefd544a814..40d97854b2f88 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerVersionCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServerVersionCapability.Serialization.cs @@ -125,7 +125,7 @@ internal static SqlServerVersionCapability DeserializeSqlServerVersionCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(EditionCapability.DeserializeEditionCapability(item, options)); + array.Add(EditionCapability.DeserializeEditionCapability(item)); } supportedEditions = array; continue; @@ -139,7 +139,7 @@ internal static SqlServerVersionCapability DeserializeSqlServerVersionCapability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ElasticPoolEditionCapability.DeserializeElasticPoolEditionCapability(item, options)); + array.Add(ElasticPoolEditionCapability.DeserializeElasticPoolEditionCapability(item)); } supportedElasticPoolEditions = array; continue; @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,17 +205,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedEditions.Any() || hasPropertyOverride) { - builder.Append(" supportedEditions:"); + builder.Append(" supportedEditions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedEditions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedEditions: "); } builder.AppendLine(" ]"); } @@ -227,17 +227,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedElasticPoolEditions.Any() || hasPropertyOverride) { - builder.Append(" supportedElasticPoolEditions:"); + builder.Append(" supportedElasticPoolEditions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedElasticPoolEditions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportedElasticPoolEditions: "); } builder.AppendLine(" ]"); } @@ -247,35 +247,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -284,12 +284,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -310,13 +313,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServicePrincipal.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServicePrincipal.Serialization.cs index 6eb571cedd0b4..c96341bd21cb5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServicePrincipal.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlServicePrincipal.Serialization.cs @@ -153,42 +153,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrincipalId), out propertyOverride); if (Optional.IsDefined(PrincipalId) || hasPropertyOverride) { - builder.Append(" principalId:"); + builder.Append(" principalId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrincipalId.Value.ToString()}'"); + builder.AppendLine($"'{PrincipalId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ClientId.Value.ToString()}'"); + builder.AppendLine($"'{ClientId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } @@ -196,12 +196,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -222,13 +225,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSku.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSku.Serialization.cs index 5307e92aecfb2..a3b45dcd9981e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSku.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSku.Serialization.cs @@ -149,21 +149,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -193,21 +193,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -215,21 +215,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -237,14 +237,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Capacity.Value}"); + builder.AppendLine($"{Capacity.Value}"); } } @@ -252,12 +252,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -278,13 +281,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspace.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspace.Serialization.cs index 1c14ed84462c3..5a179878c19f1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspace.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspace.Serialization.cs @@ -152,7 +152,7 @@ internal static SqlSynapseLinkWorkspace DeserializeSqlSynapseLinkWorkspace(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SqlSynapseLinkWorkspaceInfo.DeserializeSqlSynapseLinkWorkspaceInfo(item, options)); + array.Add(SqlSynapseLinkWorkspaceInfo.DeserializeSqlSynapseLinkWorkspaceInfo(item)); } workspaces = array; continue; @@ -183,21 +183,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,28 +205,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -237,17 +237,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Workspaces.Any() || hasPropertyOverride) { - builder.Append(" workspaces:"); + builder.Append(" workspaces: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Workspaces) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " workspaces: "); } builder.AppendLine(" ]"); } @@ -259,12 +259,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -285,13 +288,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspaceInfo.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspaceInfo.Serialization.cs index 2f041403cbc10..81d953cbe7a50 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspaceInfo.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlSynapseLinkWorkspaceInfo.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceId), out propertyOverride); if (Optional.IsDefined(WorkspaceId) || hasPropertyOverride) { - builder.Append(" workspaceId:"); + builder.Append(" workspaceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WorkspaceId.ToString()}'"); + builder.AppendLine($"'{WorkspaceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinkConnectionName), out propertyOverride); if (Optional.IsDefined(LinkConnectionName) || hasPropertyOverride) { - builder.Append(" linkConnectionName:"); + builder.Append(" linkConnectionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LinkConnectionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LinkConnectionName}'''"); } else { - builder.AppendLine($" '{LinkConnectionName}'"); + builder.AppendLine($"'{LinkConnectionName}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineAdjustedResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineAdjustedResult.Serialization.cs index a26020db72fec..888b5eee0c04b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineAdjustedResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineAdjustedResult.Serialization.cs @@ -131,7 +131,7 @@ internal static SqlVulnerabilityAssessmentBaselineAdjustedResult DeserializeSqlV { continue; } - baseline = SqlVulnerabilityAssessmentBaselineDetails.DeserializeSqlVulnerabilityAssessmentBaselineDetails(property.Value, options); + baseline = SqlVulnerabilityAssessmentBaselineDetails.DeserializeSqlVulnerabilityAssessmentBaselineDetails(property.Value); continue; } if (property.NameEquals("status"u8)) @@ -218,28 +218,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Baseline), out propertyOverride); if (Optional.IsDefined(Baseline) || hasPropertyOverride) { - builder.Append(" baseline:"); + builder.Append(" baseline: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Baseline, options, 2, false); + AppendChildObject(builder, Baseline, options, 2, false, " baseline: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } @@ -248,14 +248,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResultsNotInBaseline.Any() || hasPropertyOverride) { - builder.Append(" resultsNotInBaseline:"); + builder.Append(" resultsNotInBaseline: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResultsNotInBaseline) { if (item == null) @@ -263,7 +263,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -293,14 +293,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResultsOnlyInBaseline.Any() || hasPropertyOverride) { - builder.Append(" resultsOnlyInBaseline:"); + builder.Append(" resultsOnlyInBaseline: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResultsOnlyInBaseline) { if (item == null) @@ -308,7 +308,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -337,12 +337,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -363,13 +366,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent.Serialization.cs index 85f982e174deb..316e21ca6bf84 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent.Serialization.cs @@ -243,21 +243,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -265,28 +265,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -295,15 +295,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLatestScan), out propertyOverride); if (Optional.IsDefined(IsLatestScan) || hasPropertyOverride) { - builder.Append(" latestScan:"); + builder.Append(" latestScan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLatestScan.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -312,23 +312,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Results.Any() || hasPropertyOverride) { - builder.Append(" results:"); + builder.Append(" results: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Results) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item.Value) { if (item0 == null) @@ -336,7 +336,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item1 in item0) { if (item1 == null) @@ -368,12 +368,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -394,13 +397,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineDetails.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineDetails.Serialization.cs index 7d5328563ae8a..39f91f715b03a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineDetails.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineDetails.Serialization.cs @@ -158,14 +158,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExpectedResults.Any() || hasPropertyOverride) { - builder.Append(" expectedResults:"); + builder.Append(" expectedResults: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExpectedResults) { if (item == null) @@ -173,7 +173,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -201,15 +201,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdatedOn), out propertyOverride); if (Optional.IsDefined(UpdatedOn) || hasPropertyOverride) { - builder.Append(" updatedTime:"); + builder.Append(" updatedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(UpdatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -217,12 +217,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -243,13 +246,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent.Serialization.cs index 20fc0b94eb83d..b3ca19bc220db 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent.Serialization.cs @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,15 +272,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLatestScan), out propertyOverride); if (Optional.IsDefined(IsLatestScan) || hasPropertyOverride) { - builder.Append(" latestScan:"); + builder.Append(" latestScan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLatestScan.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -289,14 +289,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Results.Any() || hasPropertyOverride) { - builder.Append(" results:"); + builder.Append(" results: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Results) { if (item == null) @@ -304,7 +304,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -334,12 +334,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -360,13 +363,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBenchmarkReference.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBenchmarkReference.Serialization.cs index e6ec90ae17e6c..816782dd225ac 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBenchmarkReference.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentBenchmarkReference.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Benchmark), out propertyOverride); if (Optional.IsDefined(Benchmark) || hasPropertyOverride) { - builder.Append(" benchmark:"); + builder.Append(" benchmark: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Benchmark.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Benchmark}'''"); } else { - builder.AppendLine($" '{Benchmark}'"); + builder.AppendLine($"'{Benchmark}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reference), out propertyOverride); if (Optional.IsDefined(Reference) || hasPropertyOverride) { - builder.Append(" reference:"); + builder.Append(" reference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reference.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reference}'''"); } else { - builder.AppendLine($" '{Reference}'"); + builder.AppendLine($"'{Reference}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentListResult.Serialization.cs index 3dab4a22c7dbf..b1ce643585805 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SqlVulnerabilityAssessmentListResult DeserializeSqlVulnerability List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentData.DeserializeSqlVulnerabilityAssessmentData(item, options)); + array.Add(SqlVulnerabilityAssessmentData.DeserializeSqlVulnerabilityAssessmentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentQueryCheck.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentQueryCheck.Serialization.cs index 3400420a4848d..742c580d8512f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentQueryCheck.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentQueryCheck.Serialization.cs @@ -177,21 +177,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Query), out propertyOverride); if (Optional.IsDefined(Query) || hasPropertyOverride) { - builder.Append(" query:"); + builder.Append(" query: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Query.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Query}'''"); } else { - builder.AppendLine($" '{Query}'"); + builder.AppendLine($"'{Query}'"); } } } @@ -201,14 +201,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExpectedResult.Any() || hasPropertyOverride) { - builder.Append(" expectedResult:"); + builder.Append(" expectedResult: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExpectedResult) { if (item == null) @@ -216,7 +216,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -246,14 +246,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ColumnNames.Any() || hasPropertyOverride) { - builder.Append(" columnNames:"); + builder.Append(" columnNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ColumnNames) { if (item == null) @@ -280,12 +280,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -306,13 +309,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRemediation.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRemediation.Serialization.cs index 59378e2d4135b..612959b58ceb4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRemediation.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRemediation.Serialization.cs @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -180,14 +180,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Scripts.Any() || hasPropertyOverride) { - builder.Append(" scripts:"); + builder.Append(" scripts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Scripts) { if (item == null) @@ -213,36 +213,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutomated), out propertyOverride); if (Optional.IsDefined(IsAutomated) || hasPropertyOverride) { - builder.Append(" automated:"); + builder.Append(" automated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutomated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PortalLink), out propertyOverride); if (Optional.IsDefined(PortalLink) || hasPropertyOverride) { - builder.Append(" portalLink:"); + builder.Append(" portalLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PortalLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PortalLink}'''"); } else { - builder.AppendLine($" '{PortalLink}'"); + builder.AppendLine($"'{PortalLink}'"); } } } @@ -251,12 +251,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -277,13 +280,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRuleMetadata.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRuleMetadata.Serialization.cs index c946b69e73006..0293a7f37b816 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRuleMetadata.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentRuleMetadata.Serialization.cs @@ -179,7 +179,7 @@ internal static SqlVulnerabilityAssessmentRuleMetadata DeserializeSqlVulnerabili { continue; } - queryCheck = SqlVulnerabilityAssessmentQueryCheck.DeserializeSqlVulnerabilityAssessmentQueryCheck(property.Value, options); + queryCheck = SqlVulnerabilityAssessmentQueryCheck.DeserializeSqlVulnerabilityAssessmentQueryCheck(property.Value); continue; } if (property.NameEquals("benchmarkReferences"u8)) @@ -191,7 +191,7 @@ internal static SqlVulnerabilityAssessmentRuleMetadata DeserializeSqlVulnerabili List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentBenchmarkReference.DeserializeSqlVulnerabilityAssessmentBenchmarkReference(item, options)); + array.Add(SqlVulnerabilityAssessmentBenchmarkReference.DeserializeSqlVulnerabilityAssessmentBenchmarkReference(item)); } benchmarkReferences = array; continue; @@ -219,21 +219,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleId), out propertyOverride); if (Optional.IsDefined(RuleId) || hasPropertyOverride) { - builder.Append(" ruleId:"); + builder.Append(" ruleId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuleId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuleId}'''"); } else { - builder.AppendLine($" '{RuleId}'"); + builder.AppendLine($"'{RuleId}'"); } } } @@ -241,35 +241,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Severity), out propertyOverride); if (Optional.IsDefined(Severity) || hasPropertyOverride) { - builder.Append(" severity:"); + builder.Append(" severity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Severity.Value.ToString()}'"); + builder.AppendLine($"'{Severity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -277,35 +277,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleType), out propertyOverride); if (Optional.IsDefined(RuleType) || hasPropertyOverride) { - builder.Append(" ruleType:"); + builder.Append(" ruleType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RuleType.Value.ToString()}'"); + builder.AppendLine($"'{RuleType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); if (Optional.IsDefined(Title) || hasPropertyOverride) { - builder.Append(" title:"); + builder.Append(" title: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Title.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Title}'''"); } else { - builder.AppendLine($" '{Title}'"); + builder.AppendLine($"'{Title}'"); } } } @@ -313,21 +313,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -335,21 +335,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rationale), out propertyOverride); if (Optional.IsDefined(Rationale) || hasPropertyOverride) { - builder.Append(" rationale:"); + builder.Append(" rationale: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Rationale.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Rationale}'''"); } else { - builder.AppendLine($" '{Rationale}'"); + builder.AppendLine($"'{Rationale}'"); } } } @@ -357,14 +357,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryCheck), out propertyOverride); if (Optional.IsDefined(QueryCheck) || hasPropertyOverride) { - builder.Append(" queryCheck:"); + builder.Append(" queryCheck: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, QueryCheck, options, 2, false); + AppendChildObject(builder, QueryCheck, options, 2, false, " queryCheck: "); } } @@ -373,17 +373,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BenchmarkReferences.Any() || hasPropertyOverride) { - builder.Append(" benchmarkReferences:"); + builder.Append(" benchmarkReferences: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BenchmarkReferences) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " benchmarkReferences: "); } builder.AppendLine(" ]"); } @@ -394,12 +394,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -420,13 +423,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanError.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanError.Serialization.cs index 3fa80eaadca24..62795ca1cf771 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanError.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanError.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); if (Optional.IsDefined(Code) || hasPropertyOverride) { - builder.Append(" code:"); + builder.Append(" code: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Code.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Code}'''"); } else { - builder.AppendLine($" '{Code}'"); + builder.AppendLine($"'{Code}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanListResult.Serialization.cs index f8bd70e9eaf16..0bf0ef4629e9e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SqlVulnerabilityAssessmentScanListResult DeserializeSqlVulnerabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentScanResultData.DeserializeSqlVulnerabilityAssessmentScanResultData(item, options)); + array.Add(SqlVulnerabilityAssessmentScanResultData.DeserializeSqlVulnerabilityAssessmentScanResultData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanRecordListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanRecordListResult.Serialization.cs index a40886bbd54f3..cf927233d6ff3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanRecordListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlVulnerabilityAssessmentScanRecordListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SqlVulnerabilityAssessmentScanRecordListResult DeserializeSqlVul List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentScanData.DeserializeSqlVulnerabilityAssessmentScanData(item, options)); + array.Add(SqlVulnerabilityAssessmentScanData.DeserializeSqlVulnerabilityAssessmentScanData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StartStopManagedInstanceScheduleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StartStopManagedInstanceScheduleListResult.Serialization.cs index 5c9b9dece6d70..270736a61a4ce 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StartStopManagedInstanceScheduleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StartStopManagedInstanceScheduleListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static StartStopManagedInstanceScheduleListResult DeserializeStartStopM List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagedInstanceStartStopScheduleData.DeserializeManagedInstanceStartStopScheduleData(item, options)); + array.Add(ManagedInstanceStartStopScheduleData.DeserializeManagedInstanceStartStopScheduleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageCapability.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageCapability.Serialization.cs index 3b55edc15a523..40786e92393fe 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageCapability.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageCapability.Serialization.cs @@ -134,49 +134,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountType), out propertyOverride); if (Optional.IsDefined(StorageAccountType) || hasPropertyOverride) { - builder.Append(" storageAccountType:"); + builder.Append(" storageAccountType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountType.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SubscriptionUsageListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SubscriptionUsageListResult.Serialization.cs index 9b3f4b2debd0e..c444eee2dba95 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SubscriptionUsageListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SubscriptionUsageListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SubscriptionUsageListResult DeserializeSubscriptionUsageListResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SubscriptionUsageData.DeserializeSubscriptionUsageData(item, options)); + array.Add(SubscriptionUsageData.DeserializeSubscriptionUsageData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SynapseLinkWorkspaceListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SynapseLinkWorkspaceListResult.Serialization.cs index f2ac3059e5cc8..4d171e169bd17 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SynapseLinkWorkspaceListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SynapseLinkWorkspaceListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static SynapseLinkWorkspaceListResult DeserializeSynapseLinkWorkspaceLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlSynapseLinkWorkspace.DeserializeSqlSynapseLinkWorkspace(item, options)); + array.Add(SqlSynapseLinkWorkspace.DeserializeSqlSynapseLinkWorkspace(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentKeyProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentKeyProperties.Serialization.cs index 00cde55270a6c..55ff3bcf1f628 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentKeyProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentKeyProperties.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncAgentKey), out propertyOverride); if (Optional.IsDefined(SyncAgentKey) || hasPropertyOverride) { - builder.Append(" syncAgentKey:"); + builder.Append(" syncAgentKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SyncAgentKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SyncAgentKey}'''"); } else { - builder.AppendLine($" '{SyncAgentKey}'"); + builder.AppendLine($"'{SyncAgentKey}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabase.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabase.Serialization.cs index afdb1f6386ef5..fc0660c32b66b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabase.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabase.Serialization.cs @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -253,28 +253,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -283,49 +283,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseType), out propertyOverride); if (Optional.IsDefined(DatabaseType) || hasPropertyOverride) { - builder.Append(" databaseType:"); + builder.Append(" databaseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseType.Value.ToString()}'"); + builder.AppendLine($"'{DatabaseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseId), out propertyOverride); if (Optional.IsDefined(DatabaseId) || hasPropertyOverride) { - builder.Append(" databaseId:"); + builder.Append(" databaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseId.Value.ToString()}'"); + builder.AppendLine($"'{DatabaseId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -333,21 +333,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -355,21 +355,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -377,21 +377,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserName), out propertyOverride); if (Optional.IsDefined(UserName) || hasPropertyOverride) { - builder.Append(" userName:"); + builder.Append(" userName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserName}'''"); } else { - builder.AppendLine($" '{UserName}'"); + builder.AppendLine($"'{UserName}'"); } } } @@ -401,12 +401,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -427,13 +430,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabaseListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabaseListResult.Serialization.cs index dcae01f8d5b9e..3fb89137cebb7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabaseListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentLinkedDatabaseListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncAgentLinkedDatabaseListResult DeserializeSyncAgentLinkedData List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncAgentLinkedDatabase.DeserializeSyncAgentLinkedDatabase(item, options)); + array.Add(SyncAgentLinkedDatabase.DeserializeSyncAgentLinkedDatabase(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentListResult.Serialization.cs index 3f6dbcb8d0e11..4726def936d95 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncAgentListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SyncAgentListResult DeserializeSyncAgentListResult(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncAgentData.DeserializeSyncAgentData(item, options)); + array.Add(SyncAgentData.DeserializeSyncAgentData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncDatabaseIdListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncDatabaseIdListResult.Serialization.cs index 13614e35bc796..d7090c9d1347a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncDatabaseIdListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncDatabaseIdListResult.Serialization.cs @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaProperties.Serialization.cs index 7b09b71d9f732..ce79efd83ba25 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaProperties.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncFullSchemaProperties DeserializeSyncFullSchemaProperties(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncFullSchemaTable.DeserializeSyncFullSchemaTable(item, options)); + array.Add(SyncFullSchemaTable.DeserializeSyncFullSchemaTable(item)); } tables = array; continue; @@ -136,17 +136,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tables.Any() || hasPropertyOverride) { - builder.Append(" tables:"); + builder.Append(" tables: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Tables) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " tables: "); } builder.AppendLine(" ]"); } @@ -156,15 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUpdateOn), out propertyOverride); if (Optional.IsDefined(LastUpdateOn) || hasPropertyOverride) { - builder.Append(" lastUpdateTime:"); + builder.Append(" lastUpdateTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastUpdateOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -172,12 +172,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -198,13 +201,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaPropertiesListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaPropertiesListResult.Serialization.cs index b2019dc973cd1..bede9ff33d83a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaPropertiesListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaPropertiesListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncFullSchemaPropertiesListResult DeserializeSyncFullSchemaProp List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncFullSchemaProperties.DeserializeSyncFullSchemaProperties(item, options)); + array.Add(SyncFullSchemaProperties.DeserializeSyncFullSchemaProperties(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTable.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTable.Serialization.cs index d0b075bbae358..89a45e8dca909 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTable.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTable.Serialization.cs @@ -115,7 +115,7 @@ internal static SyncFullSchemaTable DeserializeSyncFullSchemaTable(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncFullSchemaTableColumn.DeserializeSyncFullSchemaTableColumn(item, options)); + array.Add(SyncFullSchemaTableColumn.DeserializeSyncFullSchemaTableColumn(item)); } columns = array; continue; @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -191,17 +191,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Columns.Any() || hasPropertyOverride) { - builder.Append(" columns:"); + builder.Append(" columns: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Columns) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " columns: "); } builder.AppendLine(" ]"); } @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorId), out propertyOverride); if (Optional.IsDefined(ErrorId) || hasPropertyOverride) { - builder.Append(" errorId:"); + builder.Append(" errorId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorId}'''"); } else { - builder.AppendLine($" '{ErrorId}'"); + builder.AppendLine($"'{ErrorId}'"); } } } @@ -233,36 +233,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasError), out propertyOverride); if (Optional.IsDefined(HasError) || hasPropertyOverride) { - builder.Append(" hasError:"); + builder.Append(" hasError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotedName), out propertyOverride); if (Optional.IsDefined(QuotedName) || hasPropertyOverride) { - builder.Append(" quotedName:"); + builder.Append(" quotedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QuotedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QuotedName}'''"); } else { - builder.AppendLine($" '{QuotedName}'"); + builder.AppendLine($"'{QuotedName}'"); } } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTableColumn.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTableColumn.Serialization.cs index e77474887a984..34c4eb8f31ff5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTableColumn.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncFullSchemaTableColumn.Serialization.cs @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -200,21 +200,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataSize), out propertyOverride); if (Optional.IsDefined(DataSize) || hasPropertyOverride) { - builder.Append(" dataSize:"); + builder.Append(" dataSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DataSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DataSize}'''"); } else { - builder.AppendLine($" '{DataSize}'"); + builder.AppendLine($"'{DataSize}'"); } } } @@ -222,21 +222,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); if (Optional.IsDefined(DataType) || hasPropertyOverride) { - builder.Append(" dataType:"); + builder.Append(" dataType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DataType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DataType}'''"); } else { - builder.AppendLine($" '{DataType}'"); + builder.AppendLine($"'{DataType}'"); } } } @@ -244,21 +244,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorId), out propertyOverride); if (Optional.IsDefined(ErrorId) || hasPropertyOverride) { - builder.Append(" errorId:"); + builder.Append(" errorId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorId}'''"); } else { - builder.AppendLine($" '{ErrorId}'"); + builder.AppendLine($"'{ErrorId}'"); } } } @@ -266,51 +266,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasError), out propertyOverride); if (Optional.IsDefined(HasError) || hasPropertyOverride) { - builder.Append(" hasError:"); + builder.Append(" hasError: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasError.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrimaryKey), out propertyOverride); if (Optional.IsDefined(IsPrimaryKey) || hasPropertyOverride) { - builder.Append(" isPrimaryKey:"); + builder.Append(" isPrimaryKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrimaryKey.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotedName), out propertyOverride); if (Optional.IsDefined(QuotedName) || hasPropertyOverride) { - builder.Append(" quotedName:"); + builder.Append(" quotedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QuotedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QuotedName}'''"); } else { - builder.AppendLine($" '{QuotedName}'"); + builder.AppendLine($"'{QuotedName}'"); } } } @@ -319,12 +319,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -345,13 +348,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupListResult.Serialization.cs index cb5b0d5237a7b..280b0b4ec028f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SyncGroupListResult DeserializeSyncGroupListResult(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncGroupData.DeserializeSyncGroupData(item, options)); + array.Add(SyncGroupData.DeserializeSyncGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogListResult.Serialization.cs index 7fdcf81abcd0a..9e6fa294b9694 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncGroupLogListResult DeserializeSyncGroupLogListResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncGroupLogProperties.DeserializeSyncGroupLogProperties(item, options)); + array.Add(SyncGroupLogProperties.DeserializeSyncGroupLogProperties(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogProperties.Serialization.cs index a51171a7abac6..ec39b39b669b4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupLogProperties.Serialization.cs @@ -171,36 +171,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Source.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Source}'''"); } else { - builder.AppendLine($" '{Source}'"); + builder.AppendLine($"'{Source}'"); } } } @@ -208,21 +208,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); if (Optional.IsDefined(Details) || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Details.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Details}'''"); } else { - builder.AppendLine($" '{Details}'"); + builder.AppendLine($"'{Details}'"); } } } @@ -230,35 +230,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TracingId), out propertyOverride); if (Optional.IsDefined(TracingId) || hasPropertyOverride) { - builder.Append(" tracingId:"); + builder.Append(" tracingId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TracingId.Value.ToString()}'"); + builder.AppendLine($"'{TracingId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationStatus), out propertyOverride); if (Optional.IsDefined(OperationStatus) || hasPropertyOverride) { - builder.Append(" operationStatus:"); + builder.Append(" operationStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationStatus.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationStatus}'''"); } else { - builder.AppendLine($" '{OperationStatus}'"); + builder.AppendLine($"'{OperationStatus}'"); } } } @@ -267,12 +267,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -293,13 +296,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchema.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchema.Serialization.cs index 5e1544a3f0307..aa73bafa4c7a1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchema.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchema.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncGroupSchema DeserializeSyncGroupSchema(JsonElement element, List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncGroupSchemaTable.DeserializeSyncGroupSchemaTable(item, options)); + array.Add(SyncGroupSchemaTable.DeserializeSyncGroupSchemaTable(item)); } tables = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tables.Any() || hasPropertyOverride) { - builder.Append(" tables:"); + builder.Append(" tables: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Tables) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " tables: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MasterSyncMemberName), out propertyOverride); if (Optional.IsDefined(MasterSyncMemberName) || hasPropertyOverride) { - builder.Append(" masterSyncMemberName:"); + builder.Append(" masterSyncMemberName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MasterSyncMemberName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MasterSyncMemberName}'''"); } else { - builder.AppendLine($" '{MasterSyncMemberName}'"); + builder.AppendLine($"'{MasterSyncMemberName}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTable.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTable.Serialization.cs index 4cac054f73d39..2a627eaa547d7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTable.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTable.Serialization.cs @@ -97,7 +97,7 @@ internal static SyncGroupSchemaTable DeserializeSyncGroupSchemaTable(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncGroupSchemaTableColumn.DeserializeSyncGroupSchemaTableColumn(item, options)); + array.Add(SyncGroupSchemaTableColumn.DeserializeSyncGroupSchemaTableColumn(item)); } columns = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Columns.Any() || hasPropertyOverride) { - builder.Append(" columns:"); + builder.Append(" columns: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Columns) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " columns: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotedName), out propertyOverride); if (Optional.IsDefined(QuotedName) || hasPropertyOverride) { - builder.Append(" quotedName:"); + builder.Append(" quotedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QuotedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QuotedName}'''"); } else { - builder.AppendLine($" '{QuotedName}'"); + builder.AppendLine($"'{QuotedName}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTableColumn.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTableColumn.Serialization.cs index eaa11fd42e9f6..872e1c4f53612 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTableColumn.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncGroupSchemaTableColumn.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotedName), out propertyOverride); if (Optional.IsDefined(QuotedName) || hasPropertyOverride) { - builder.Append(" quotedName:"); + builder.Append(" quotedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (QuotedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{QuotedName}'''"); } else { - builder.AppendLine($" '{QuotedName}'"); + builder.AppendLine($"'{QuotedName}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataSize), out propertyOverride); if (Optional.IsDefined(DataSize) || hasPropertyOverride) { - builder.Append(" dataSize:"); + builder.Append(" dataSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DataSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DataSize}'''"); } else { - builder.AppendLine($" '{DataSize}'"); + builder.AppendLine($"'{DataSize}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); if (Optional.IsDefined(DataType) || hasPropertyOverride) { - builder.Append(" dataType:"); + builder.Append(" dataType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DataType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DataType}'''"); } else { - builder.AppendLine($" '{DataType}'"); + builder.AppendLine($"'{DataType}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncMemberListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncMemberListResult.Serialization.cs index a0f92d6219847..7d3f6630be079 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncMemberListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SyncMemberListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static SyncMemberListResult DeserializeSyncMemberListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SyncMemberData.DeserializeSyncMemberData(item, options)); + array.Add(SyncMemberData.DeserializeSyncMemberData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TdeCertificate.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TdeCertificate.Serialization.cs index 5ee82e45a8105..a4569a9c4df66 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TdeCertificate.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TdeCertificate.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,28 +201,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateBlob), out propertyOverride); if (Optional.IsDefined(PrivateBlob) || hasPropertyOverride) { - builder.Append(" privateBlob:"); + builder.Append(" privateBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrivateBlob.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrivateBlob}'''"); } else { - builder.AppendLine($" '{PrivateBlob}'"); + builder.AppendLine($"'{PrivateBlob}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertPassword), out propertyOverride); if (Optional.IsDefined(CertPassword) || hasPropertyOverride) { - builder.Append(" certPassword:"); + builder.Append(" certPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertPassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertPassword}'''"); } else { - builder.AppendLine($" '{CertPassword}'"); + builder.AppendLine($"'{CertPassword}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TimeZoneListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TimeZoneListResult.Serialization.cs index 25ed181ab1990..1f6faafa9a7b7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TimeZoneListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TimeZoneListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static TimeZoneListResult DeserializeTimeZoneListResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlTimeZoneData.DeserializeSqlTimeZoneData(item, options)); + array.Add(SqlTimeZoneData.DeserializeSqlTimeZoneData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueries.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueries.Serialization.cs index 03b90f0a5bce8..33cd2a60420ca 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueries.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueries.Serialization.cs @@ -165,7 +165,7 @@ internal static TopQueries DeserializeTopQueries(JsonElement element, ModelReade List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryStatisticsProperties.DeserializeQueryStatisticsProperties(item, options)); + array.Add(QueryStatisticsProperties.DeserializeQueryStatisticsProperties(item)); } queries = array; continue; @@ -193,35 +193,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfQueries), out propertyOverride); if (Optional.IsDefined(NumberOfQueries) || hasPropertyOverride) { - builder.Append(" numberOfQueries:"); + builder.Append(" numberOfQueries: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfQueries.Value}"); + builder.AppendLine($"{NumberOfQueries.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AggregationFunction), out propertyOverride); if (Optional.IsDefined(AggregationFunction) || hasPropertyOverride) { - builder.Append(" aggregationFunction:"); + builder.Append(" aggregationFunction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AggregationFunction.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AggregationFunction}'''"); } else { - builder.AppendLine($" '{AggregationFunction}'"); + builder.AppendLine($"'{AggregationFunction}'"); } } } @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObservationMetric), out propertyOverride); if (Optional.IsDefined(ObservationMetric) || hasPropertyOverride) { - builder.Append(" observationMetric:"); + builder.Append(" observationMetric: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ObservationMetric.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ObservationMetric}'''"); } else { - builder.AppendLine($" '{ObservationMetric}'"); + builder.AppendLine($"'{ObservationMetric}'"); } } } @@ -251,35 +251,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IntervalType), out propertyOverride); if (Optional.IsDefined(IntervalType) || hasPropertyOverride) { - builder.Append(" intervalType:"); + builder.Append(" intervalType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IntervalType.Value.ToString()}'"); + builder.AppendLine($"'{IntervalType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -287,21 +287,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndTime), out propertyOverride); if (Optional.IsDefined(EndTime) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndTime}'''"); } else { - builder.AppendLine($" '{EndTime}'"); + builder.AppendLine($"'{EndTime}'"); } } } @@ -311,17 +311,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Queries.Any() || hasPropertyOverride) { - builder.Append(" queries:"); + builder.Append(" queries: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Queries) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " queries: "); } builder.AppendLine(" ]"); } @@ -332,12 +332,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -358,13 +361,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueriesListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueriesListResult.Serialization.cs index b3f9be85725fe..c06b6a4e8b963 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueriesListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TopQueriesListResult.Serialization.cs @@ -97,7 +97,7 @@ internal static TopQueriesListResult DeserializeTopQueriesListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TopQueries.DeserializeTopQueries(item, options)); + array.Add(TopQueries.DeserializeTopQueries(item)); } value = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationParameters.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationParameters.Serialization.cs index 5c77d90f5f513..95eca36a49ff9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationParameters.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationParameters.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -189,28 +189,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); if (Optional.IsDefined(VCores) || hasPropertyOverride) { - builder.Append(" vCores:"); + builder.Append(" vCores: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VCores.Value}"); + builder.AppendLine($"{VCores.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageSizeInGB), out propertyOverride); if (Optional.IsDefined(StorageSizeInGB) || hasPropertyOverride) { - builder.Append(" storageSizeInGB:"); + builder.Append(" storageSizeInGB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StorageSizeInGB.Value}"); + builder.AppendLine($"{StorageSizeInGB.Value}"); } } @@ -218,12 +218,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -244,13 +247,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationStep.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationStep.Serialization.cs index 159f8677b76cc..38b20feb3229c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationStep.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpsertManagedServerOperationStep.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,28 +156,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Order), out propertyOverride); if (Optional.IsDefined(Order) || hasPropertyOverride) { - builder.Append(" order:"); + builder.Append(" order: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Order.Value}"); + builder.AppendLine($"{Order.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualClusterListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualClusterListResult.Serialization.cs index dff6b6b42268e..4e8865c1c96f7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualClusterListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualClusterListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static VirtualClusterListResult DeserializeVirtualClusterListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VirtualClusterData.DeserializeVirtualClusterData(item, options)); + array.Add(VirtualClusterData.DeserializeVirtualClusterData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualNetworkRuleListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualNetworkRuleListResult.Serialization.cs index f86846650e950..75ddc827743e5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualNetworkRuleListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VirtualNetworkRuleListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static VirtualNetworkRuleListResult DeserializeVirtualNetworkRuleListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SqlServerVirtualNetworkRuleData.DeserializeSqlServerVirtualNetworkRuleData(item, options)); + array.Add(SqlServerVirtualNetworkRuleData.DeserializeSqlServerVirtualNetworkRuleData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentRecurringScansProperties.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentRecurringScansProperties.Serialization.cs index 7eeda7230a668..2eef143f3f669 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentRecurringScansProperties.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentRecurringScansProperties.Serialization.cs @@ -149,30 +149,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" isEnabled:"); + builder.Append(" isEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EmailSubscriptionAdmins), out propertyOverride); if (Optional.IsDefined(EmailSubscriptionAdmins) || hasPropertyOverride) { - builder.Append(" emailSubscriptionAdmins:"); + builder.Append(" emailSubscriptionAdmins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EmailSubscriptionAdmins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -181,14 +181,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Emails.Any() || hasPropertyOverride) { - builder.Append(" emails:"); + builder.Append(" emails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Emails) { if (item == null) @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanError.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanError.Serialization.cs index 1c993cfca48d2..adcd4ccfd7001 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanError.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanError.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); if (Optional.IsDefined(Code) || hasPropertyOverride) { - builder.Append(" code:"); + builder.Append(" code: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Code.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Code}'''"); } else { - builder.AppendLine($" '{Code}'"); + builder.AppendLine($"'{Code}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanRecordListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanRecordListResult.Serialization.cs index 99cc7e1ffae80..2eb786c763b89 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanRecordListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/VulnerabilityAssessmentScanRecordListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static VulnerabilityAssessmentScanRecordListResult DeserializeVulnerabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VulnerabilityAssessmentScanRecordData.DeserializeVulnerabilityAssessmentScanRecordData(item, options)); + array.Add(VulnerabilityAssessmentScanRecordData.DeserializeVulnerabilityAssessmentScanRecordData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadClassifierListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadClassifierListResult.Serialization.cs index 9377be54283b5..172792f0c37d8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadClassifierListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadClassifierListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static WorkloadClassifierListResult DeserializeWorkloadClassifierListRe List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(WorkloadClassifierData.DeserializeWorkloadClassifierData(item, options)); + array.Add(WorkloadClassifierData.DeserializeWorkloadClassifierData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadGroupListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadGroupListResult.Serialization.cs index a495bb6566a0a..a032e39c31d51 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadGroupListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/WorkloadGroupListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static WorkloadGroupListResult DeserializeWorkloadGroupListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(WorkloadGroupData.DeserializeWorkloadGroupData(item, options)); + array.Add(WorkloadGroupData.DeserializeWorkloadGroupData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/OutboundFirewallRuleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/OutboundFirewallRuleData.Serialization.cs index b2eaa442572a2..33cdd7a12d5b0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/OutboundFirewallRuleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/OutboundFirewallRuleData.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecommendedActionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecommendedActionData.Serialization.cs index 988ea452b0032..2dcf69bc4a1b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecommendedActionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecommendedActionData.Serialization.cs @@ -364,7 +364,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme { continue; } - state = RecommendedActionStateInfo.DeserializeRecommendedActionStateInfo(property0.Value, options); + state = RecommendedActionStateInfo.DeserializeRecommendedActionStateInfo(property0.Value); continue; } if (property0.NameEquals("isExecutableAction"u8)) @@ -481,7 +481,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme { continue; } - implementationDetails = RecommendedActionImplementationInfo.DeserializeRecommendedActionImplementationInfo(property0.Value, options); + implementationDetails = RecommendedActionImplementationInfo.DeserializeRecommendedActionImplementationInfo(property0.Value); continue; } if (property0.NameEquals("errorDetails"u8)) @@ -490,7 +490,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme { continue; } - errorDetails = RecommendedActionErrorInfo.DeserializeRecommendedActionErrorInfo(property0.Value, options); + errorDetails = RecommendedActionErrorInfo.DeserializeRecommendedActionErrorInfo(property0.Value); continue; } if (property0.NameEquals("estimatedImpact"u8)) @@ -502,7 +502,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(RecommendedActionImpactRecord.DeserializeRecommendedActionImpactRecord(item, options)); + array.Add(RecommendedActionImpactRecord.DeserializeRecommendedActionImpactRecord(item)); } estimatedImpact = array; continue; @@ -516,7 +516,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(RecommendedActionImpactRecord.DeserializeRecommendedActionImpactRecord(item, options)); + array.Add(RecommendedActionImpactRecord.DeserializeRecommendedActionImpactRecord(item)); } observedImpact = array; continue; @@ -530,7 +530,7 @@ internal static RecommendedActionData DeserializeRecommendedActionData(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(RecommendedActionMetricInfo.DeserializeRecommendedActionMetricInfo(item, options)); + array.Add(RecommendedActionMetricInfo.DeserializeRecommendedActionMetricInfo(item)); } timeSeries = array; continue; @@ -596,21 +596,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -618,35 +618,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -654,28 +654,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -684,21 +684,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationReason), out propertyOverride); if (Optional.IsDefined(RecommendationReason) || hasPropertyOverride) { - builder.Append(" recommendationReason:"); + builder.Append(" recommendationReason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RecommendationReason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RecommendationReason}'''"); } else { - builder.AppendLine($" '{RecommendationReason}'"); + builder.AppendLine($"'{RecommendationReason}'"); } } } @@ -706,249 +706,249 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidSince), out propertyOverride); if (Optional.IsDefined(ValidSince) || hasPropertyOverride) { - builder.Append(" validSince:"); + builder.Append(" validSince: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ValidSince.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRefresh), out propertyOverride); if (Optional.IsDefined(LastRefresh) || hasPropertyOverride) { - builder.Append(" lastRefresh:"); + builder.Append(" lastRefresh: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastRefresh.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, State, options, 4, false); + AppendChildObject(builder, State, options, 4, false, " state: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsExecutableAction), out propertyOverride); if (Optional.IsDefined(IsExecutableAction) || hasPropertyOverride) { - builder.Append(" isExecutableAction:"); + builder.Append(" isExecutableAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsExecutableAction.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRevertableAction), out propertyOverride); if (Optional.IsDefined(IsRevertableAction) || hasPropertyOverride) { - builder.Append(" isRevertableAction:"); + builder.Append(" isRevertableAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRevertableAction.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchivedAction), out propertyOverride); if (Optional.IsDefined(IsArchivedAction) || hasPropertyOverride) { - builder.Append(" isArchivedAction:"); + builder.Append(" isArchivedAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsArchivedAction.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecuteActionStartOn), out propertyOverride); if (Optional.IsDefined(ExecuteActionStartOn) || hasPropertyOverride) { - builder.Append(" executeActionStartTime:"); + builder.Append(" executeActionStartTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExecuteActionStartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecuteActionDuration), out propertyOverride); if (Optional.IsDefined(ExecuteActionDuration) || hasPropertyOverride) { - builder.Append(" executeActionDuration:"); + builder.Append(" executeActionDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(ExecuteActionDuration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevertActionStartOn), out propertyOverride); if (Optional.IsDefined(RevertActionStartOn) || hasPropertyOverride) { - builder.Append(" revertActionStartTime:"); + builder.Append(" revertActionStartTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RevertActionStartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevertActionDuration), out propertyOverride); if (Optional.IsDefined(RevertActionDuration) || hasPropertyOverride) { - builder.Append(" revertActionDuration:"); + builder.Append(" revertActionDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(RevertActionDuration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecuteActionInitiatedBy), out propertyOverride); if (Optional.IsDefined(ExecuteActionInitiatedBy) || hasPropertyOverride) { - builder.Append(" executeActionInitiatedBy:"); + builder.Append(" executeActionInitiatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExecuteActionInitiatedBy.Value.ToSerialString()}'"); + builder.AppendLine($"'{ExecuteActionInitiatedBy.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecuteActionInitiatedOn), out propertyOverride); if (Optional.IsDefined(ExecuteActionInitiatedOn) || hasPropertyOverride) { - builder.Append(" executeActionInitiatedTime:"); + builder.Append(" executeActionInitiatedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExecuteActionInitiatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevertActionInitiatedBy), out propertyOverride); if (Optional.IsDefined(RevertActionInitiatedBy) || hasPropertyOverride) { - builder.Append(" revertActionInitiatedBy:"); + builder.Append(" revertActionInitiatedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RevertActionInitiatedBy.Value.ToSerialString()}'"); + builder.AppendLine($"'{RevertActionInitiatedBy.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevertActionInitiatedOn), out propertyOverride); if (Optional.IsDefined(RevertActionInitiatedOn) || hasPropertyOverride) { - builder.Append(" revertActionInitiatedTime:"); + builder.Append(" revertActionInitiatedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RevertActionInitiatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Score), out propertyOverride); if (Optional.IsDefined(Score) || hasPropertyOverride) { - builder.Append(" score:"); + builder.Append(" score: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Score.Value}"); + builder.AppendLine($"{Score.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImplementationDetails), out propertyOverride); if (Optional.IsDefined(ImplementationDetails) || hasPropertyOverride) { - builder.Append(" implementationDetails:"); + builder.Append(" implementationDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ImplementationDetails, options, 4, false); + AppendChildObject(builder, ImplementationDetails, options, 4, false, " implementationDetails: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorDetails), out propertyOverride); if (Optional.IsDefined(ErrorDetails) || hasPropertyOverride) { - builder.Append(" errorDetails:"); + builder.Append(" errorDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ErrorDetails, options, 4, false); + AppendChildObject(builder, ErrorDetails, options, 4, false, " errorDetails: "); } } @@ -957,17 +957,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EstimatedImpact.Any() || hasPropertyOverride) { - builder.Append(" estimatedImpact:"); + builder.Append(" estimatedImpact: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EstimatedImpact) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " estimatedImpact: "); } builder.AppendLine(" ]"); } @@ -979,17 +979,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ObservedImpact.Any() || hasPropertyOverride) { - builder.Append(" observedImpact:"); + builder.Append(" observedImpact: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ObservedImpact) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " observedImpact: "); } builder.AppendLine(" ]"); } @@ -1001,17 +1001,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TimeSeries.Any() || hasPropertyOverride) { - builder.Append(" timeSeries:"); + builder.Append(" timeSeries: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TimeSeries) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " timeSeries: "); } builder.AppendLine(" ]"); } @@ -1023,14 +1023,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LinkedObjects.Any() || hasPropertyOverride) { - builder.Append(" linkedObjects:"); + builder.Append(" linkedObjects: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LinkedObjects) { if (item == null) @@ -1058,23 +1058,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Details.Any() || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Details) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -1086,12 +1086,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1112,13 +1115,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableDatabaseData.Serialization.cs index 4a65dc6990676..33759d452bea9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableDatabaseData.Serialization.cs @@ -202,7 +202,7 @@ internal static RecoverableDatabaseData DeserializeRecoverableDatabaseData(JsonE Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value, options)); + dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value)); } keys = dictionary; continue; @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -255,28 +255,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -285,21 +285,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Edition), out propertyOverride); if (Optional.IsDefined(Edition) || hasPropertyOverride) { - builder.Append(" edition:"); + builder.Append(" edition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Edition.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Edition}'''"); } else { - builder.AppendLine($" '{Edition}'"); + builder.AppendLine($"'{Edition}'"); } } } @@ -307,21 +307,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceLevelObjective), out propertyOverride); if (Optional.IsDefined(ServiceLevelObjective) || hasPropertyOverride) { - builder.Append(" serviceLevelObjective:"); + builder.Append(" serviceLevelObjective: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceLevelObjective.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceLevelObjective}'''"); } else { - builder.AppendLine($" '{ServiceLevelObjective}'"); + builder.AppendLine($"'{ServiceLevelObjective}'"); } } } @@ -329,21 +329,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticPoolName), out propertyOverride); if (Optional.IsDefined(ElasticPoolName) || hasPropertyOverride) { - builder.Append(" elasticPoolName:"); + builder.Append(" elasticPoolName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ElasticPoolName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ElasticPoolName}'''"); } else { - builder.AppendLine($" '{ElasticPoolName}'"); + builder.AppendLine($"'{ElasticPoolName}'"); } } } @@ -351,15 +351,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastAvailableBackupOn), out propertyOverride); if (Optional.IsDefined(LastAvailableBackupOn) || hasPropertyOverride) { - builder.Append(" lastAvailableBackupDate:"); + builder.Append(" lastAvailableBackupDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastAvailableBackupOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -368,18 +368,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Keys.Any() || hasPropertyOverride) { - builder.Append(" keys:"); + builder.Append(" keys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Keys) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " keys: "); } builder.AppendLine(" }"); } @@ -391,12 +391,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -417,13 +420,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableManagedDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableManagedDatabaseData.Serialization.cs index 57cd5a31287c4..0125ac78d6456 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableManagedDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RecoverableManagedDatabaseData.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastAvailableBackupDate), out propertyOverride); if (Optional.IsDefined(LastAvailableBackupDate) || hasPropertyOverride) { - builder.Append(" lastAvailableBackupDate:"); + builder.Append(" lastAvailableBackupDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastAvailableBackupDate.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastAvailableBackupDate}'''"); } else { - builder.AppendLine($" '{LastAvailableBackupDate}'"); + builder.AppendLine($"'{LastAvailableBackupDate}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.Serialization.cs index c9e1589174faf..bad06f90c827b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.Serialization.cs @@ -175,7 +175,7 @@ internal static RestorableDroppedDatabaseData DeserializeRestorableDroppedDataba { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -289,7 +289,7 @@ internal static RestorableDroppedDatabaseData DeserializeRestorableDroppedDataba Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value, options)); + dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value)); } keys = dictionary; continue; @@ -320,21 +320,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -342,14 +342,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -358,17 +358,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -376,12 +376,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -392,42 +392,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -436,21 +436,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -458,73 +458,73 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxSizeBytes), out propertyOverride); if (Optional.IsDefined(MaxSizeBytes) || hasPropertyOverride) { - builder.Append(" maxSizeBytes:"); + builder.Append(" maxSizeBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxSizeBytes.Value.ToString()}'"); + builder.AppendLine($"'{MaxSizeBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionDate:"); + builder.Append(" deletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) { - builder.Append(" earliestRestoreDate:"); + builder.Append(" earliestRestoreDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(BackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" backupStorageRedundancy:"); + builder.Append(" backupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{BackupStorageRedundancy.Value.ToString()}'"); } } @@ -533,18 +533,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Keys.Any() || hasPropertyOverride) { - builder.Append(" keys:"); + builder.Append(" keys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Keys) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " keys: "); } builder.AppendLine(" }"); } @@ -556,12 +556,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -582,13 +585,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedManagedDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedManagedDatabaseData.Serialization.cs index cc77cea95c7b1..e16a6b98d22be 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedManagedDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedManagedDatabaseData.Serialization.cs @@ -248,21 +248,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -270,14 +270,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -286,17 +286,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -304,12 +304,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -320,28 +320,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -372,45 +372,45 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionDate:"); + builder.Append(" deletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) { - builder.Append(" earliestRestoreDate:"); + builder.Append(" earliestRestoreDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -419,12 +419,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -445,13 +448,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SensitivityLabelData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SensitivityLabelData.Serialization.cs index 982c7fa6a0619..f805dfbead6d8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SensitivityLabelData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SensitivityLabelData.Serialization.cs @@ -276,21 +276,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -298,21 +298,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -320,28 +320,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SchemaName), out propertyOverride); if (Optional.IsDefined(SchemaName) || hasPropertyOverride) { - builder.Append(" schemaName:"); + builder.Append(" schemaName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SchemaName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SchemaName}'''"); } else { - builder.AppendLine($" '{SchemaName}'"); + builder.AppendLine($"'{SchemaName}'"); } } } @@ -372,21 +372,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); if (Optional.IsDefined(TableName) || hasPropertyOverride) { - builder.Append(" tableName:"); + builder.Append(" tableName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TableName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TableName}'''"); } else { - builder.AppendLine($" '{TableName}'"); + builder.AppendLine($"'{TableName}'"); } } } @@ -394,21 +394,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnName), out propertyOverride); if (Optional.IsDefined(ColumnName) || hasPropertyOverride) { - builder.Append(" columnName:"); + builder.Append(" columnName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ColumnName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ColumnName}'''"); } else { - builder.AppendLine($" '{ColumnName}'"); + builder.AppendLine($"'{ColumnName}'"); } } } @@ -416,21 +416,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LabelName), out propertyOverride); if (Optional.IsDefined(LabelName) || hasPropertyOverride) { - builder.Append(" labelName:"); + builder.Append(" labelName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LabelName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LabelName}'''"); } else { - builder.AppendLine($" '{LabelName}'"); + builder.AppendLine($"'{LabelName}'"); } } } @@ -438,21 +438,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LabelId), out propertyOverride); if (Optional.IsDefined(LabelId) || hasPropertyOverride) { - builder.Append(" labelId:"); + builder.Append(" labelId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LabelId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LabelId}'''"); } else { - builder.AppendLine($" '{LabelId}'"); + builder.AppendLine($"'{LabelId}'"); } } } @@ -460,21 +460,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InformationType), out propertyOverride); if (Optional.IsDefined(InformationType) || hasPropertyOverride) { - builder.Append(" informationType:"); + builder.Append(" informationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InformationType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InformationType}'''"); } else { - builder.AppendLine($" '{InformationType}'"); + builder.AppendLine($"'{InformationType}'"); } } } @@ -482,21 +482,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InformationTypeId), out propertyOverride); if (Optional.IsDefined(InformationTypeId) || hasPropertyOverride) { - builder.Append(" informationTypeId:"); + builder.Append(" informationTypeId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InformationTypeId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InformationTypeId}'''"); } else { - builder.AppendLine($" '{InformationTypeId}'"); + builder.AppendLine($"'{InformationTypeId}'"); } } } @@ -504,29 +504,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDisabled), out propertyOverride); if (Optional.IsDefined(IsDisabled) || hasPropertyOverride) { - builder.Append(" isDisabled:"); + builder.Append(" isDisabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDisabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rank), out propertyOverride); if (Optional.IsDefined(Rank) || hasPropertyOverride) { - builder.Append(" rank:"); + builder.Append(" rank: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Rank.Value.ToSerialString()}'"); + builder.AppendLine($"'{Rank.Value.ToSerialString()}'"); } } @@ -535,12 +535,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -561,13 +564,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.Serialization.cs index e860e62a905c0..d07fc91d4a714 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.Serialization.cs @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.Serialization.cs index 78b280ff915a2..8cd9fafe35e55 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.Serialization.cs @@ -190,21 +190,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -212,28 +212,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicBlob), out propertyOverride); if (Optional.IsDefined(PublicBlob) || hasPropertyOverride) { - builder.Append(" publicBlob:"); + builder.Append(" publicBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicBlob.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicBlob}'''"); } else { - builder.AppendLine($" '{PublicBlob}'"); + builder.AppendLine($"'{PublicBlob}'"); } } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificateName), out propertyOverride); if (Optional.IsDefined(CertificateName) || hasPropertyOverride) { - builder.Append(" certificateName:"); + builder.Append(" certificateName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertificateName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertificateName}'''"); } else { - builder.AppendLine($" '{CertificateName}'"); + builder.AppendLine($"'{CertificateName}'"); } } } @@ -310,12 +310,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -336,13 +339,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServiceObjectiveData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServiceObjectiveData.Serialization.cs index c6637a677df1a..11e8414a91b20 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServiceObjectiveData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServiceObjectiveData.Serialization.cs @@ -224,21 +224,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -246,28 +246,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -276,21 +276,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceObjectiveName), out propertyOverride); if (Optional.IsDefined(ServiceObjectiveName) || hasPropertyOverride) { - builder.Append(" serviceObjectiveName:"); + builder.Append(" serviceObjectiveName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceObjectiveName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceObjectiveName}'''"); } else { - builder.AppendLine($" '{ServiceObjectiveName}'"); + builder.AppendLine($"'{ServiceObjectiveName}'"); } } } @@ -298,51 +298,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefault), out propertyOverride); if (Optional.IsDefined(IsDefault) || hasPropertyOverride) { - builder.Append(" isDefault:"); + builder.Append(" isDefault: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefault.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSystem), out propertyOverride); if (Optional.IsDefined(IsSystem) || hasPropertyOverride) { - builder.Append(" isSystem:"); + builder.Append(" isSystem: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSystem.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -350,15 +350,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -367,12 +367,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -393,13 +396,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAdvisorData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAdvisorData.Serialization.cs index 3b0c4fdf59ec4..05211113326cd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAdvisorData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAdvisorData.Serialization.cs @@ -250,7 +250,7 @@ internal static SqlAdvisorData DeserializeSqlAdvisorData(JsonElement element, Mo List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(RecommendedActionData.DeserializeRecommendedActionData(item, options)); + array.Add(RecommendedActionData.DeserializeRecommendedActionData(item)); } recommendedActions = array; continue; @@ -281,21 +281,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -303,35 +303,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -339,28 +339,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -369,63 +369,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdvisorStatus), out propertyOverride); if (Optional.IsDefined(AdvisorStatus) || hasPropertyOverride) { - builder.Append(" advisorStatus:"); + builder.Append(" advisorStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AdvisorStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{AdvisorStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoExecuteStatus), out propertyOverride); if (Optional.IsDefined(AutoExecuteStatus) || hasPropertyOverride) { - builder.Append(" autoExecuteStatus:"); + builder.Append(" autoExecuteStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AutoExecuteStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{AutoExecuteStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoExecuteStatusInheritedFrom), out propertyOverride); if (Optional.IsDefined(AutoExecuteStatusInheritedFrom) || hasPropertyOverride) { - builder.Append(" autoExecuteStatusInheritedFrom:"); + builder.Append(" autoExecuteStatusInheritedFrom: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AutoExecuteStatusInheritedFrom.Value.ToSerialString()}'"); + builder.AppendLine($"'{AutoExecuteStatusInheritedFrom.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationsStatus), out propertyOverride); if (Optional.IsDefined(RecommendationsStatus) || hasPropertyOverride) { - builder.Append(" recommendationsStatus:"); + builder.Append(" recommendationsStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RecommendationsStatus.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RecommendationsStatus}'''"); } else { - builder.AppendLine($" '{RecommendationsStatus}'"); + builder.AppendLine($"'{RecommendationsStatus}'"); } } } @@ -433,15 +433,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastCheckedOn), out propertyOverride); if (Optional.IsDefined(LastCheckedOn) || hasPropertyOverride) { - builder.Append(" lastChecked:"); + builder.Append(" lastChecked: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastCheckedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -450,17 +450,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RecommendedActions.Any() || hasPropertyOverride) { - builder.Append(" recommendedActions:"); + builder.Append(" recommendedActions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RecommendedActions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " recommendedActions: "); } builder.AppendLine(" ]"); } @@ -472,12 +472,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -498,13 +501,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAgentConfigurationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAgentConfigurationData.Serialization.cs index f5cee6a51e594..735e54a2757b0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAgentConfigurationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlAgentConfigurationData.Serialization.cs @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseAutomaticTuningData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseAutomaticTuningData.Serialization.cs index 75285e6768830..6104dde7654a6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseAutomaticTuningData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseAutomaticTuningData.Serialization.cs @@ -184,7 +184,7 @@ internal static SqlDatabaseAutomaticTuningData DeserializeSqlDatabaseAutomaticTu Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, AutomaticTuningOptions.DeserializeAutomaticTuningOptions(property1.Value, options)); + dictionary.Add(property1.Name, AutomaticTuningOptions.DeserializeAutomaticTuningOptions(property1.Value)); } options0 = dictionary; continue; @@ -215,21 +215,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -237,28 +237,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -267,28 +267,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DesiredState), out propertyOverride); if (Optional.IsDefined(DesiredState) || hasPropertyOverride) { - builder.Append(" desiredState:"); + builder.Append(" desiredState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DesiredState.Value.ToSerialString()}'"); + builder.AppendLine($"'{DesiredState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActualState), out propertyOverride); if (Optional.IsDefined(ActualState) || hasPropertyOverride) { - builder.Append(" actualState:"); + builder.Append(" actualState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActualState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActualState.Value.ToSerialString()}'"); } } @@ -297,18 +297,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Options.Any() || hasPropertyOverride) { - builder.Append(" options:"); + builder.Append(" options: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Options) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " options: "); } builder.AppendLine(" }"); } @@ -320,12 +320,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -346,13 +349,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseBlobAuditingPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseBlobAuditingPolicyData.Serialization.cs index d74846ce3abce..5956ff83a6210 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseBlobAuditingPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseBlobAuditingPolicyData.Serialization.cs @@ -322,21 +322,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -344,21 +344,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -366,28 +366,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -396,14 +396,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } @@ -412,14 +412,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AuditActionsAndGroups.Any() || hasPropertyOverride) { - builder.Append(" auditActionsAndGroups:"); + builder.Append(" auditActionsAndGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AuditActionsAndGroups) { if (item == null) @@ -445,94 +445,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageSecondaryKeyInUse), out propertyOverride); if (Optional.IsDefined(IsStorageSecondaryKeyInUse) || hasPropertyOverride) { - builder.Append(" isStorageSecondaryKeyInUse:"); + builder.Append(" isStorageSecondaryKeyInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageSecondaryKeyInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureMonitorTargetEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureMonitorTargetEnabled) || hasPropertyOverride) { - builder.Append(" isAzureMonitorTargetEnabled:"); + builder.Append(" isAzureMonitorTargetEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureMonitorTargetEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueDelayMs), out propertyOverride); if (Optional.IsDefined(QueueDelayMs) || hasPropertyOverride) { - builder.Append(" queueDelayMs:"); + builder.Append(" queueDelayMs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {QueueDelayMs.Value}"); + builder.AppendLine($"{QueueDelayMs.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManagedIdentityInUse), out propertyOverride); if (Optional.IsDefined(IsManagedIdentityInUse) || hasPropertyOverride) { - builder.Append(" isManagedIdentityInUse:"); + builder.Append(" isManagedIdentityInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManagedIdentityInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -540,21 +540,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -562,14 +562,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSubscriptionId), out propertyOverride); if (Optional.IsDefined(StorageAccountSubscriptionId) || hasPropertyOverride) { - builder.Append(" storageAccountSubscriptionId:"); + builder.Append(" storageAccountSubscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountSubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountSubscriptionId.Value.ToString()}'"); } } @@ -578,12 +578,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -604,13 +607,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.Serialization.cs index c9020bbb8046c..c6a4d9f3c145d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.Serialization.cs @@ -439,7 +439,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element, { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("kind"u8)) @@ -458,7 +458,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element, { continue; } - identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value, options); + identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -750,7 +750,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element, { continue; } - currentSku = SqlSku.DeserializeSqlSku(property0.Value, options); + currentSku = SqlSku.DeserializeSqlSku(property0.Value); continue; } if (property0.NameEquals("autoPauseDelay"u8)) @@ -852,7 +852,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element, Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value, options)); + dictionary.Add(property1.Name, SqlDatabaseKey.DeserializeSqlDatabaseKey(property1.Value)); } keys = dictionary; continue; @@ -960,21 +960,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -982,14 +982,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -998,17 +998,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -1016,12 +1016,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -1032,35 +1032,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -1068,21 +1068,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) { - builder.Append(" managedBy:"); + builder.Append(" managedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ManagedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ManagedBy}'''"); } else { - builder.AppendLine($" '{ManagedBy}'"); + builder.AppendLine($"'{ManagedBy}'"); } } } @@ -1090,42 +1090,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -1134,35 +1134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); if (Optional.IsDefined(CreateMode) || hasPropertyOverride) { - builder.Append(" createMode:"); + builder.Append(" createMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CreateMode.Value.ToString()}'"); + builder.AppendLine($"'{CreateMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Collation), out propertyOverride); if (Optional.IsDefined(Collation) || hasPropertyOverride) { - builder.Append(" collation:"); + builder.Append(" collation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Collation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Collation}'''"); } else { - builder.AppendLine($" '{Collation}'"); + builder.AppendLine($"'{Collation}'"); } } } @@ -1170,120 +1170,120 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxSizeBytes), out propertyOverride); if (Optional.IsDefined(MaxSizeBytes) || hasPropertyOverride) { - builder.Append(" maxSizeBytes:"); + builder.Append(" maxSizeBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxSizeBytes.Value.ToString()}'"); + builder.AppendLine($"'{MaxSizeBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SampleName), out propertyOverride); if (Optional.IsDefined(SampleName) || hasPropertyOverride) { - builder.Append(" sampleName:"); + builder.Append(" sampleName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SampleName.Value.ToString()}'"); + builder.AppendLine($"'{SampleName.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticPoolId), out propertyOverride); if (Optional.IsDefined(ElasticPoolId) || hasPropertyOverride) { - builder.Append(" elasticPoolId:"); + builder.Append(" elasticPoolId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ElasticPoolId.ToString()}'"); + builder.AppendLine($"'{ElasticPoolId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceDatabaseId), out propertyOverride); if (Optional.IsDefined(SourceDatabaseId) || hasPropertyOverride) { - builder.Append(" sourceDatabaseId:"); + builder.Append(" sourceDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceDatabaseId.ToString()}'"); + builder.AppendLine($"'{SourceDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseId), out propertyOverride); if (Optional.IsDefined(DatabaseId) || hasPropertyOverride) { - builder.Append(" databaseId:"); + builder.Append(" databaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseId.Value.ToString()}'"); + builder.AppendLine($"'{DatabaseId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentServiceObjectiveName), out propertyOverride); if (Optional.IsDefined(CurrentServiceObjectiveName) || hasPropertyOverride) { - builder.Append(" currentServiceObjectiveName:"); + builder.Append(" currentServiceObjectiveName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentServiceObjectiveName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentServiceObjectiveName}'''"); } else { - builder.AppendLine($" '{CurrentServiceObjectiveName}'"); + builder.AppendLine($"'{CurrentServiceObjectiveName}'"); } } } @@ -1291,21 +1291,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedServiceObjectiveName), out propertyOverride); if (Optional.IsDefined(RequestedServiceObjectiveName) || hasPropertyOverride) { - builder.Append(" requestedServiceObjectiveName:"); + builder.Append(" requestedServiceObjectiveName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RequestedServiceObjectiveName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RequestedServiceObjectiveName}'''"); } else { - builder.AppendLine($" '{RequestedServiceObjectiveName}'"); + builder.AppendLine($"'{RequestedServiceObjectiveName}'"); } } } @@ -1313,386 +1313,386 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultSecondaryLocation), out propertyOverride); if (Optional.IsDefined(DefaultSecondaryLocation) || hasPropertyOverride) { - builder.Append(" defaultSecondaryLocation:"); + builder.Append(" defaultSecondaryLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultSecondaryLocation.Value.ToString()}'"); + builder.AppendLine($"'{DefaultSecondaryLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailoverGroupId), out propertyOverride); if (Optional.IsDefined(FailoverGroupId) || hasPropertyOverride) { - builder.Append(" failoverGroupId:"); + builder.Append(" failoverGroupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FailoverGroupId.ToString()}'"); + builder.AppendLine($"'{FailoverGroupId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointInTime), out propertyOverride); if (Optional.IsDefined(RestorePointInTime) || hasPropertyOverride) { - builder.Append(" restorePointInTime:"); + builder.Append(" restorePointInTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestorePointInTime.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceDatabaseDeletedOn), out propertyOverride); if (Optional.IsDefined(SourceDatabaseDeletedOn) || hasPropertyOverride) { - builder.Append(" sourceDatabaseDeletionDate:"); + builder.Append(" sourceDatabaseDeletionDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SourceDatabaseDeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoveryServicesRecoveryPointId), out propertyOverride); if (Optional.IsDefined(RecoveryServicesRecoveryPointId) || hasPropertyOverride) { - builder.Append(" recoveryServicesRecoveryPointId:"); + builder.Append(" recoveryServicesRecoveryPointId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RecoveryServicesRecoveryPointId.ToString()}'"); + builder.AppendLine($"'{RecoveryServicesRecoveryPointId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LongTermRetentionBackupResourceId), out propertyOverride); if (Optional.IsDefined(LongTermRetentionBackupResourceId) || hasPropertyOverride) { - builder.Append(" longTermRetentionBackupResourceId:"); + builder.Append(" longTermRetentionBackupResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LongTermRetentionBackupResourceId.ToString()}'"); + builder.AppendLine($"'{LongTermRetentionBackupResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoverableDatabaseId), out propertyOverride); if (Optional.IsDefined(RecoverableDatabaseId) || hasPropertyOverride) { - builder.Append(" recoverableDatabaseId:"); + builder.Append(" recoverableDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RecoverableDatabaseId.ToString()}'"); + builder.AppendLine($"'{RecoverableDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorableDroppedDatabaseId), out propertyOverride); if (Optional.IsDefined(RestorableDroppedDatabaseId) || hasPropertyOverride) { - builder.Append(" restorableDroppedDatabaseId:"); + builder.Append(" restorableDroppedDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RestorableDroppedDatabaseId.ToString()}'"); + builder.AppendLine($"'{RestorableDroppedDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CatalogCollation), out propertyOverride); if (Optional.IsDefined(CatalogCollation) || hasPropertyOverride) { - builder.Append(" catalogCollation:"); + builder.Append(" catalogCollation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CatalogCollation.Value.ToString()}'"); + builder.AppendLine($"'{CatalogCollation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LicenseType), out propertyOverride); if (Optional.IsDefined(LicenseType) || hasPropertyOverride) { - builder.Append(" licenseType:"); + builder.Append(" licenseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LicenseType.Value.ToString()}'"); + builder.AppendLine($"'{LicenseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxLogSizeBytes), out propertyOverride); if (Optional.IsDefined(MaxLogSizeBytes) || hasPropertyOverride) { - builder.Append(" maxLogSizeBytes:"); + builder.Append(" maxLogSizeBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxLogSizeBytes.Value.ToString()}'"); + builder.AppendLine($"'{MaxLogSizeBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) { - builder.Append(" earliestRestoreDate:"); + builder.Append(" earliestRestoreDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReadScale), out propertyOverride); if (Optional.IsDefined(ReadScale) || hasPropertyOverride) { - builder.Append(" readScale:"); + builder.Append(" readScale: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReadScale.Value.ToString()}'"); + builder.AppendLine($"'{ReadScale.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HighAvailabilityReplicaCount), out propertyOverride); if (Optional.IsDefined(HighAvailabilityReplicaCount) || hasPropertyOverride) { - builder.Append(" highAvailabilityReplicaCount:"); + builder.Append(" highAvailabilityReplicaCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {HighAvailabilityReplicaCount.Value}"); + builder.AppendLine($"{HighAvailabilityReplicaCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondaryType), out propertyOverride); if (Optional.IsDefined(SecondaryType) || hasPropertyOverride) { - builder.Append(" secondaryType:"); + builder.Append(" secondaryType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SecondaryType.Value.ToString()}'"); + builder.AppendLine($"'{SecondaryType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentSku), out propertyOverride); if (Optional.IsDefined(CurrentSku) || hasPropertyOverride) { - builder.Append(" currentSku:"); + builder.Append(" currentSku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CurrentSku, options, 4, false); + AppendChildObject(builder, CurrentSku, options, 4, false, " currentSku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoPauseDelay), out propertyOverride); if (Optional.IsDefined(AutoPauseDelay) || hasPropertyOverride) { - builder.Append(" autoPauseDelay:"); + builder.Append(" autoPauseDelay: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {AutoPauseDelay.Value}"); + builder.AppendLine($"{AutoPauseDelay.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(CurrentBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" currentBackupStorageRedundancy:"); + builder.Append(" currentBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{CurrentBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestedBackupStorageRedundancy), out propertyOverride); if (Optional.IsDefined(RequestedBackupStorageRedundancy) || hasPropertyOverride) { - builder.Append(" requestedBackupStorageRedundancy:"); + builder.Append(" requestedBackupStorageRedundancy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RequestedBackupStorageRedundancy.Value.ToString()}'"); + builder.AppendLine($"'{RequestedBackupStorageRedundancy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCapacity), out propertyOverride); if (Optional.IsDefined(MinCapacity) || hasPropertyOverride) { - builder.Append(" minCapacity:"); + builder.Append(" minCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinCapacity.Value.ToString()}'"); + builder.AppendLine($"'{MinCapacity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PausedOn), out propertyOverride); if (Optional.IsDefined(PausedOn) || hasPropertyOverride) { - builder.Append(" pausedDate:"); + builder.Append(" pausedDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(PausedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResumedOn), out propertyOverride); if (Optional.IsDefined(ResumedOn) || hasPropertyOverride) { - builder.Append(" resumedDate:"); + builder.Append(" resumedDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ResumedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaintenanceConfigurationId), out propertyOverride); if (Optional.IsDefined(MaintenanceConfigurationId) || hasPropertyOverride) { - builder.Append(" maintenanceConfigurationId:"); + builder.Append(" maintenanceConfigurationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaintenanceConfigurationId.ToString()}'"); + builder.AppendLine($"'{MaintenanceConfigurationId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLedgerOn), out propertyOverride); if (Optional.IsDefined(IsLedgerOn) || hasPropertyOverride) { - builder.Append(" isLedgerOn:"); + builder.Append(" isLedgerOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLedgerOn.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInfraEncryptionEnabled), out propertyOverride); if (Optional.IsDefined(IsInfraEncryptionEnabled) || hasPropertyOverride) { - builder.Append(" isInfraEncryptionEnabled:"); + builder.Append(" isInfraEncryptionEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInfraEncryptionEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FederatedClientId), out propertyOverride); if (Optional.IsDefined(FederatedClientId) || hasPropertyOverride) { - builder.Append(" federatedClientId:"); + builder.Append(" federatedClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FederatedClientId.Value.ToString()}'"); + builder.AppendLine($"'{FederatedClientId.Value.ToString()}'"); } } @@ -1701,18 +1701,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Keys.Any() || hasPropertyOverride) { - builder.Append(" keys:"); + builder.Append(" keys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Keys) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " keys: "); } builder.AppendLine(" }"); } @@ -1722,21 +1722,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncryptionProtector), out propertyOverride); if (Optional.IsDefined(EncryptionProtector) || hasPropertyOverride) { - builder.Append(" encryptionProtector:"); + builder.Append(" encryptionProtector: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EncryptionProtector.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EncryptionProtector}'''"); } else { - builder.AppendLine($" '{EncryptionProtector}'"); + builder.AppendLine($"'{EncryptionProtector}'"); } } } @@ -1744,116 +1744,116 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreferredEnclaveType), out propertyOverride); if (Optional.IsDefined(PreferredEnclaveType) || hasPropertyOverride) { - builder.Append(" preferredEnclaveType:"); + builder.Append(" preferredEnclaveType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PreferredEnclaveType.Value.ToString()}'"); + builder.AppendLine($"'{PreferredEnclaveType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UseFreeLimit), out propertyOverride); if (Optional.IsDefined(UseFreeLimit) || hasPropertyOverride) { - builder.Append(" useFreeLimit:"); + builder.Append(" useFreeLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UseFreeLimit.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FreeLimitExhaustionBehavior), out propertyOverride); if (Optional.IsDefined(FreeLimitExhaustionBehavior) || hasPropertyOverride) { - builder.Append(" freeLimitExhaustionBehavior:"); + builder.Append(" freeLimitExhaustionBehavior: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FreeLimitExhaustionBehavior.Value.ToString()}'"); + builder.AppendLine($"'{FreeLimitExhaustionBehavior.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceResourceId), out propertyOverride); if (Optional.IsDefined(SourceResourceId) || hasPropertyOverride) { - builder.Append(" sourceResourceId:"); + builder.Append(" sourceResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceResourceId.ToString()}'"); + builder.AppendLine($"'{SourceResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManualCutover), out propertyOverride); if (Optional.IsDefined(ManualCutover) || hasPropertyOverride) { - builder.Append(" manualCutover:"); + builder.Append(" manualCutover: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ManualCutover.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PerformCutover), out propertyOverride); if (Optional.IsDefined(PerformCutover) || hasPropertyOverride) { - builder.Append(" performCutover:"); + builder.Append(" performCutover: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = PerformCutover.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailabilityZone), out propertyOverride); if (Optional.IsDefined(AvailabilityZone) || hasPropertyOverride) { - builder.Append(" availabilityZone:"); + builder.Append(" availabilityZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AvailabilityZone.Value.ToString()}'"); + builder.AppendLine($"'{AvailabilityZone.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncryptionProtectorAutoRotation), out propertyOverride); if (Optional.IsDefined(EncryptionProtectorAutoRotation) || hasPropertyOverride) { - builder.Append(" encryptionProtectorAutoRotation:"); + builder.Append(" encryptionProtectorAutoRotation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EncryptionProtectorAutoRotation.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -1862,12 +1862,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1888,13 +1891,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseSecurityAlertPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseSecurityAlertPolicyData.Serialization.cs index dab594a3cfd87..71801c8918efa 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseSecurityAlertPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseSecurityAlertPolicyData.Serialization.cs @@ -291,21 +291,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -313,28 +313,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -343,14 +343,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -359,14 +359,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DisabledAlerts.Any() || hasPropertyOverride) { - builder.Append(" disabledAlerts:"); + builder.Append(" disabledAlerts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DisabledAlerts) { if (item == null) @@ -394,14 +394,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EmailAddresses.Any() || hasPropertyOverride) { - builder.Append(" emailAddresses:"); + builder.Append(" emailAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EmailAddresses) { if (item == null) @@ -427,36 +427,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendToEmailAccountAdmins), out propertyOverride); if (Optional.IsDefined(SendToEmailAccountAdmins) || hasPropertyOverride) { - builder.Append(" emailAccountAdmins:"); + builder.Append(" emailAccountAdmins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SendToEmailAccountAdmins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -464,21 +464,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -486,29 +486,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -517,12 +517,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -543,13 +546,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlFirewallRuleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlFirewallRuleData.Serialization.cs index 9700c0bbb8158..c67ca9c3409ae 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlFirewallRuleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlFirewallRuleData.Serialization.cs @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,14 +193,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartIPAddress), out propertyOverride); if (Optional.IsDefined(StartIPAddress) || hasPropertyOverride) { - builder.Append(" startIpAddress:"); + builder.Append(" startIpAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartIPAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartIPAddress}'''"); } else { - builder.AppendLine($" '{StartIPAddress}'"); + builder.AppendLine($"'{StartIPAddress}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndIPAddress), out propertyOverride); if (Optional.IsDefined(EndIPAddress) || hasPropertyOverride) { - builder.Append(" endIpAddress:"); + builder.Append(" endIpAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndIPAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndIPAddress}'''"); } else { - builder.AppendLine($" '{EndIPAddress}'"); + builder.AppendLine($"'{EndIPAddress}'"); } } } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateEndpointConnectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateEndpointConnectionData.Serialization.cs index 3e1cfc1ba66ac..6d4ab88046b1e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateEndpointConnectionData.Serialization.cs @@ -192,7 +192,7 @@ internal static SqlPrivateEndpointConnectionData DeserializeSqlPrivateEndpointCo { continue; } - privateLinkServiceConnectionState = SqlPrivateLinkServiceConnectionStateProperty.DeserializeSqlPrivateLinkServiceConnectionStateProperty(property0.Value, options); + privateLinkServiceConnectionState = SqlPrivateLinkServiceConnectionStateProperty.DeserializeSqlPrivateLinkServiceConnectionStateProperty(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -230,21 +230,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -252,28 +252,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -282,14 +282,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } @@ -298,14 +298,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GroupIds.Any() || hasPropertyOverride) { - builder.Append(" groupIds:"); + builder.Append(" groupIds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GroupIds) { if (item == null) @@ -331,28 +331,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -361,12 +361,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -387,13 +390,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateLinkResourceData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateLinkResourceData.Serialization.cs index 68c4c7582977f..ce84a9997b818 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateLinkResourceData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlPrivateLinkResourceData.Serialization.cs @@ -108,7 +108,7 @@ internal static SqlPrivateLinkResourceData DeserializeSqlPrivateLinkResourceData { continue; } - properties = SqlPrivateLinkResourceProperties.DeserializeSqlPrivateLinkResourceProperties(property.Value, options); + properties = SqlPrivateLinkResourceProperties.DeserializeSqlPrivateLinkResourceProperties(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -180,42 +180,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAutomaticTuningData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAutomaticTuningData.Serialization.cs index af687e42d5e39..35b98322d267b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAutomaticTuningData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAutomaticTuningData.Serialization.cs @@ -184,7 +184,7 @@ internal static SqlServerAutomaticTuningData DeserializeSqlServerAutomaticTuning Dictionary dictionary = new Dictionary(); foreach (var property1 in property0.Value.EnumerateObject()) { - dictionary.Add(property1.Name, AutomaticTuningServerOptions.DeserializeAutomaticTuningServerOptions(property1.Value, options)); + dictionary.Add(property1.Name, AutomaticTuningServerOptions.DeserializeAutomaticTuningServerOptions(property1.Value)); } options0 = dictionary; continue; @@ -215,21 +215,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -237,28 +237,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -267,28 +267,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DesiredState), out propertyOverride); if (Optional.IsDefined(DesiredState) || hasPropertyOverride) { - builder.Append(" desiredState:"); + builder.Append(" desiredState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DesiredState.Value.ToSerialString()}'"); + builder.AppendLine($"'{DesiredState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActualState), out propertyOverride); if (Optional.IsDefined(ActualState) || hasPropertyOverride) { - builder.Append(" actualState:"); + builder.Append(" actualState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActualState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActualState.Value.ToSerialString()}'"); } } @@ -297,18 +297,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Options.Any() || hasPropertyOverride) { - builder.Append(" options:"); + builder.Append(" options: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Options) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " options: "); } builder.AppendLine(" }"); } @@ -320,12 +320,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -346,13 +349,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADAdministratorData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADAdministratorData.Serialization.cs index cc331175426d1..7ef002e04495b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADAdministratorData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADAdministratorData.Serialization.cs @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -251,28 +251,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -281,35 +281,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) { - builder.Append(" administratorType:"); + builder.Append(" administratorType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AdministratorType.Value.ToString()}'"); + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Login.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Login}'''"); } else { - builder.AppendLine($" '{Login}'"); + builder.AppendLine($"'{Login}'"); } } } @@ -317,43 +317,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); if (Optional.IsDefined(Sid) || hasPropertyOverride) { - builder.Append(" sid:"); + builder.Append(" sid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Sid.Value.ToString()}'"); + builder.AppendLine($"'{Sid.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureADOnlyAuthenticationEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureADOnlyAuthenticationEnabled) || hasPropertyOverride) { - builder.Append(" azureADOnlyAuthentication:"); + builder.Append(" azureADOnlyAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureADOnlyAuthenticationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -362,12 +362,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -388,13 +391,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADOnlyAuthenticationData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADOnlyAuthenticationData.Serialization.cs index 12babffd4c735..0b91d45c9d618 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADOnlyAuthenticationData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerAzureADOnlyAuthenticationData.Serialization.cs @@ -172,21 +172,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -194,28 +194,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -224,15 +224,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureADOnlyAuthenticationEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureADOnlyAuthenticationEnabled) || hasPropertyOverride) { - builder.Append(" azureADOnlyAuthentication:"); + builder.Append(" azureADOnlyAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureADOnlyAuthenticationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerBlobAuditingPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerBlobAuditingPolicyData.Serialization.cs index 7c48bbe6f923b..450d30df15fe0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerBlobAuditingPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerBlobAuditingPolicyData.Serialization.cs @@ -326,21 +326,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -348,28 +348,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -378,29 +378,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDevopsAuditEnabled), out propertyOverride); if (Optional.IsDefined(IsDevopsAuditEnabled) || hasPropertyOverride) { - builder.Append(" isDevopsAuditEnabled:"); + builder.Append(" isDevopsAuditEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDevopsAuditEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } @@ -409,14 +409,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AuditActionsAndGroups.Any() || hasPropertyOverride) { - builder.Append(" auditActionsAndGroups:"); + builder.Append(" auditActionsAndGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AuditActionsAndGroups) { if (item == null) @@ -442,94 +442,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageSecondaryKeyInUse), out propertyOverride); if (Optional.IsDefined(IsStorageSecondaryKeyInUse) || hasPropertyOverride) { - builder.Append(" isStorageSecondaryKeyInUse:"); + builder.Append(" isStorageSecondaryKeyInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageSecondaryKeyInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureMonitorTargetEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureMonitorTargetEnabled) || hasPropertyOverride) { - builder.Append(" isAzureMonitorTargetEnabled:"); + builder.Append(" isAzureMonitorTargetEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureMonitorTargetEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueDelayMs), out propertyOverride); if (Optional.IsDefined(QueueDelayMs) || hasPropertyOverride) { - builder.Append(" queueDelayMs:"); + builder.Append(" queueDelayMs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {QueueDelayMs.Value}"); + builder.AppendLine($"{QueueDelayMs.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManagedIdentityInUse), out propertyOverride); if (Optional.IsDefined(IsManagedIdentityInUse) || hasPropertyOverride) { - builder.Append(" isManagedIdentityInUse:"); + builder.Append(" isManagedIdentityInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManagedIdentityInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -537,21 +537,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -559,14 +559,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSubscriptionId), out propertyOverride); if (Optional.IsDefined(StorageAccountSubscriptionId) || hasPropertyOverride) { - builder.Append(" storageAccountSubscriptionId:"); + builder.Append(" storageAccountSubscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountSubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountSubscriptionId.Value.ToString()}'"); } } @@ -575,12 +575,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -601,13 +604,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerCommunicationLinkData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerCommunicationLinkData.Serialization.cs index 9102e6d2ad0ed..42799183a7cfb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerCommunicationLinkData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerCommunicationLinkData.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,35 +227,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -263,28 +263,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -293,21 +293,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -315,21 +315,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerServer), out propertyOverride); if (Optional.IsDefined(PartnerServer) || hasPropertyOverride) { - builder.Append(" partnerServer:"); + builder.Append(" partnerServer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PartnerServer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PartnerServer}'''"); } else { - builder.AppendLine($" '{PartnerServer}'"); + builder.AppendLine($"'{PartnerServer}'"); } } } @@ -339,12 +339,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -365,13 +368,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerConnectionPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerConnectionPolicyData.Serialization.cs index a17c13c604442..0ad53b31981fc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerConnectionPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerConnectionPolicyData.Serialization.cs @@ -199,21 +199,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -221,35 +221,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -257,28 +257,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -287,14 +287,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionType), out propertyOverride); if (Optional.IsDefined(ConnectionType) || hasPropertyOverride) { - builder.Append(" connectionType:"); + builder.Append(" connectionType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ConnectionType.Value.ToString()}'"); + builder.AppendLine($"'{ConnectionType.Value.ToString()}'"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerData.Serialization.cs index 885d3a83b828a..ed819e8f24c81 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerData.Serialization.cs @@ -330,7 +330,7 @@ internal static SqlServerData DeserializeSqlServerData(JsonElement element, Mode List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SqlServerPrivateEndpointConnection.DeserializeSqlServerPrivateEndpointConnection(item, options)); + array.Add(SqlServerPrivateEndpointConnection.DeserializeSqlServerPrivateEndpointConnection(item)); } privateEndpointConnections = array; continue; @@ -395,7 +395,7 @@ internal static SqlServerData DeserializeSqlServerData(JsonElement element, Mode { continue; } - administrators = ServerExternalAdministrator.DeserializeServerExternalAdministrator(property0.Value, options); + administrators = ServerExternalAdministrator.DeserializeServerExternalAdministrator(property0.Value); continue; } if (property0.NameEquals("restrictOutboundNetworkAccess"u8)) @@ -451,21 +451,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -473,14 +473,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -489,17 +489,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -507,12 +507,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -523,35 +523,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -559,28 +559,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -589,21 +589,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLogin), out propertyOverride); if (Optional.IsDefined(AdministratorLogin) || hasPropertyOverride) { - builder.Append(" administratorLogin:"); + builder.Append(" administratorLogin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AdministratorLogin.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AdministratorLogin}'''"); } else { - builder.AppendLine($" '{AdministratorLogin}'"); + builder.AppendLine($"'{AdministratorLogin}'"); } } } @@ -611,21 +611,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLoginPassword), out propertyOverride); if (Optional.IsDefined(AdministratorLoginPassword) || hasPropertyOverride) { - builder.Append(" administratorLoginPassword:"); + builder.Append(" administratorLoginPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AdministratorLoginPassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AdministratorLoginPassword}'''"); } else { - builder.AppendLine($" '{AdministratorLoginPassword}'"); + builder.AppendLine($"'{AdministratorLoginPassword}'"); } } } @@ -633,21 +633,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -655,21 +655,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -677,21 +677,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainName), out propertyOverride); if (Optional.IsDefined(FullyQualifiedDomainName) || hasPropertyOverride) { - builder.Append(" fullyQualifiedDomainName:"); + builder.Append(" fullyQualifiedDomainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FullyQualifiedDomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FullyQualifiedDomainName}'''"); } else { - builder.AppendLine($" '{FullyQualifiedDomainName}'"); + builder.AppendLine($"'{FullyQualifiedDomainName}'"); } } } @@ -701,17 +701,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -721,140 +721,140 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinTlsVersion), out propertyOverride); if (Optional.IsDefined(MinTlsVersion) || hasPropertyOverride) { - builder.Append(" minimalTlsVersion:"); + builder.Append(" minimalTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{MinTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicNetworkAccess.Value.ToString()}'"); + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceFeature), out propertyOverride); if (Optional.IsDefined(WorkspaceFeature) || hasPropertyOverride) { - builder.Append(" workspaceFeature:"); + builder.Append(" workspaceFeature: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WorkspaceFeature.Value.ToString()}'"); + builder.AppendLine($"'{WorkspaceFeature.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryUserAssignedIdentityId), out propertyOverride); if (Optional.IsDefined(PrimaryUserAssignedIdentityId) || hasPropertyOverride) { - builder.Append(" primaryUserAssignedIdentityId:"); + builder.Append(" primaryUserAssignedIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryUserAssignedIdentityId.ToString()}'"); + builder.AppendLine($"'{PrimaryUserAssignedIdentityId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FederatedClientId), out propertyOverride); if (Optional.IsDefined(FederatedClientId) || hasPropertyOverride) { - builder.Append(" federatedClientId:"); + builder.Append(" federatedClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FederatedClientId.Value.ToString()}'"); + builder.AppendLine($"'{FederatedClientId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyId), out propertyOverride); if (Optional.IsDefined(KeyId) || hasPropertyOverride) { - builder.Append(" keyId:"); + builder.Append(" keyId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyId.AbsoluteUri}'"); + builder.AppendLine($"'{KeyId.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Administrators), out propertyOverride); if (Optional.IsDefined(Administrators) || hasPropertyOverride) { - builder.Append(" administrators:"); + builder.Append(" administrators: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Administrators, options, 4, false); + AppendChildObject(builder, Administrators, options, 4, false, " administrators: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestrictOutboundNetworkAccess), out propertyOverride); if (Optional.IsDefined(RestrictOutboundNetworkAccess) || hasPropertyOverride) { - builder.Append(" restrictOutboundNetworkAccess:"); + builder.Append(" restrictOutboundNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RestrictOutboundNetworkAccess.Value.ToString()}'"); + builder.AppendLine($"'{RestrictOutboundNetworkAccess.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsIPv6Enabled), out propertyOverride); if (Optional.IsDefined(IsIPv6Enabled) || hasPropertyOverride) { - builder.Append(" isIPv6Enabled:"); + builder.Append(" isIPv6Enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IsIPv6Enabled.Value.ToString()}'"); + builder.AppendLine($"'{IsIPv6Enabled.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExternalGovernanceStatus), out propertyOverride); if (Optional.IsDefined(ExternalGovernanceStatus) || hasPropertyOverride) { - builder.Append(" externalGovernanceStatus:"); + builder.Append(" externalGovernanceStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExternalGovernanceStatus.Value.ToString()}'"); + builder.AppendLine($"'{ExternalGovernanceStatus.Value.ToString()}'"); } } @@ -863,12 +863,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -889,13 +892,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseReplicationLinkData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseReplicationLinkData.Serialization.cs index ea1925349f43b..9eed318cc3bdf 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseReplicationLinkData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseReplicationLinkData.Serialization.cs @@ -311,21 +311,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -333,28 +333,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerServer), out propertyOverride); if (Optional.IsDefined(PartnerServer) || hasPropertyOverride) { - builder.Append(" partnerServer:"); + builder.Append(" partnerServer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PartnerServer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PartnerServer}'''"); } else { - builder.AppendLine($" '{PartnerServer}'"); + builder.AppendLine($"'{PartnerServer}'"); } } } @@ -385,21 +385,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerDatabase), out propertyOverride); if (Optional.IsDefined(PartnerDatabase) || hasPropertyOverride) { - builder.Append(" partnerDatabase:"); + builder.Append(" partnerDatabase: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PartnerDatabase.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PartnerDatabase}'''"); } else { - builder.AppendLine($" '{PartnerDatabase}'"); + builder.AppendLine($"'{PartnerDatabase}'"); } } } @@ -407,63 +407,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerLocation), out propertyOverride); if (Optional.IsDefined(PartnerLocation) || hasPropertyOverride) { - builder.Append(" partnerLocation:"); + builder.Append(" partnerLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PartnerLocation.Value.ToString()}'"); + builder.AppendLine($"'{PartnerLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Role), out propertyOverride); if (Optional.IsDefined(Role) || hasPropertyOverride) { - builder.Append(" role:"); + builder.Append(" role: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Role.Value.ToSerialString()}'"); + builder.AppendLine($"'{Role.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PartnerRole), out propertyOverride); if (Optional.IsDefined(PartnerRole) || hasPropertyOverride) { - builder.Append(" partnerRole:"); + builder.Append(" partnerRole: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PartnerRole.Value.ToSerialString()}'"); + builder.AppendLine($"'{PartnerRole.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationMode), out propertyOverride); if (Optional.IsDefined(ReplicationMode) || hasPropertyOverride) { - builder.Append(" replicationMode:"); + builder.Append(" replicationMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ReplicationMode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ReplicationMode}'''"); } else { - builder.AppendLine($" '{ReplicationMode}'"); + builder.AppendLine($"'{ReplicationMode}'"); } } } @@ -471,72 +471,72 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) { - builder.Append(" percentComplete:"); + builder.Append(" percentComplete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PercentComplete.Value}"); + builder.AppendLine($"{PercentComplete.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationState), out propertyOverride); if (Optional.IsDefined(ReplicationState) || hasPropertyOverride) { - builder.Append(" replicationState:"); + builder.Append(" replicationState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReplicationState.Value.ToString()}'"); + builder.AppendLine($"'{ReplicationState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsTerminationAllowed), out propertyOverride); if (Optional.IsDefined(IsTerminationAllowed) || hasPropertyOverride) { - builder.Append(" isTerminationAllowed:"); + builder.Append(" isTerminationAllowed: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsTerminationAllowed.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinkType), out propertyOverride); if (Optional.IsDefined(LinkType) || hasPropertyOverride) { - builder.Append(" linkType:"); + builder.Append(" linkType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LinkType.Value.ToString()}'"); + builder.AppendLine($"'{LinkType.Value.ToString()}'"); } } @@ -545,12 +545,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -571,13 +574,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseRestorePointData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseRestorePointData.Serialization.cs index 2dee110e19ecc..e6ffc92b62d8c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseRestorePointData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDatabaseRestorePointData.Serialization.cs @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -251,42 +251,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -295,65 +295,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointType), out propertyOverride); if (Optional.IsDefined(RestorePointType) || hasPropertyOverride) { - builder.Append(" restorePointType:"); + builder.Append(" restorePointType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RestorePointType.Value.ToSerialString()}'"); + builder.AppendLine($"'{RestorePointType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) { - builder.Append(" earliestRestoreDate:"); + builder.Append(" earliestRestoreDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointCreatedOn), out propertyOverride); if (Optional.IsDefined(RestorePointCreatedOn) || hasPropertyOverride) { - builder.Append(" restorePointCreationDate:"); + builder.Append(" restorePointCreationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RestorePointCreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointLabel), out propertyOverride); if (Optional.IsDefined(RestorePointLabel) || hasPropertyOverride) { - builder.Append(" restorePointLabel:"); + builder.Append(" restorePointLabel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RestorePointLabel.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RestorePointLabel}'''"); } else { - builder.AppendLine($" '{RestorePointLabel}'"); + builder.AppendLine($"'{RestorePointLabel}'"); } } } @@ -363,12 +363,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -389,13 +392,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDevOpsAuditingSettingData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDevOpsAuditingSettingData.Serialization.cs index a4f887caaa335..7c3b48f5709f9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDevOpsAuditingSettingData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDevOpsAuditingSettingData.Serialization.cs @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -262,28 +262,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -292,65 +292,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAzureMonitorTargetEnabled), out propertyOverride); if (Optional.IsDefined(IsAzureMonitorTargetEnabled) || hasPropertyOverride) { - builder.Append(" isAzureMonitorTargetEnabled:"); + builder.Append(" isAzureMonitorTargetEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAzureMonitorTargetEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManagedIdentityInUse), out propertyOverride); if (Optional.IsDefined(IsManagedIdentityInUse) || hasPropertyOverride) { - builder.Append(" isManagedIdentityInUse:"); + builder.Append(" isManagedIdentityInUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManagedIdentityInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -358,21 +358,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -380,14 +380,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSubscriptionId), out propertyOverride); if (Optional.IsDefined(StorageAccountSubscriptionId) || hasPropertyOverride) { - builder.Append(" storageAccountSubscriptionId:"); + builder.Append(" storageAccountSubscriptionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountSubscriptionId.Value.ToString()}'"); + builder.AppendLine($"'{StorageAccountSubscriptionId.Value.ToString()}'"); } } @@ -396,12 +396,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -422,13 +425,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDnsAliasData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDnsAliasData.Serialization.cs index bf236f6323f87..4336dc61ae927 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDnsAliasData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerDnsAliasData.Serialization.cs @@ -168,21 +168,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -190,28 +190,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureDnsRecord), out propertyOverride); if (Optional.IsDefined(AzureDnsRecord) || hasPropertyOverride) { - builder.Append(" azureDnsRecord:"); + builder.Append(" azureDnsRecord: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzureDnsRecord.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzureDnsRecord}'''"); } else { - builder.AppendLine($" '{AzureDnsRecord}'"); + builder.AppendLine($"'{AzureDnsRecord}'"); } } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobAgentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobAgentData.Serialization.cs index 733317f0456fc..2520661bc6631 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobAgentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobAgentData.Serialization.cs @@ -139,7 +139,7 @@ internal static SqlServerJobAgentData DeserializeSqlServerJobAgentData(JsonEleme { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -260,14 +260,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -276,17 +276,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -294,12 +294,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -310,42 +310,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -354,28 +354,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseId), out propertyOverride); if (Optional.IsDefined(DatabaseId) || hasPropertyOverride) { - builder.Append(" databaseId:"); + builder.Append(" databaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseId.ToString()}'"); + builder.AppendLine($"'{DatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } @@ -384,12 +384,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -410,13 +413,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobCredentialData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobCredentialData.Serialization.cs index f4d16075d47ee..e771f78e76a53 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobCredentialData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobCredentialData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,28 +201,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Username), out propertyOverride); if (Optional.IsDefined(Username) || hasPropertyOverride) { - builder.Append(" username:"); + builder.Append(" username: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Username.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Username}'''"); } else { - builder.AppendLine($" '{Username}'"); + builder.AppendLine($"'{Username}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); if (Optional.IsDefined(Password) || hasPropertyOverride) { - builder.Append(" password:"); + builder.Append(" password: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Password.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Password}'''"); } else { - builder.AppendLine($" '{Password}'"); + builder.AppendLine($"'{Password}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobData.Serialization.cs index 61f5c15f4a44b..765753d27ec0a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobData.Serialization.cs @@ -170,7 +170,7 @@ internal static SqlServerJobData DeserializeSqlServerJobData(JsonElement element { continue; } - schedule = SqlServerJobSchedule.DeserializeSqlServerJobSchedule(property0.Value, options); + schedule = SqlServerJobSchedule.DeserializeSqlServerJobSchedule(property0.Value); continue; } } @@ -199,21 +199,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -221,28 +221,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -273,28 +273,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Version.Value}"); + builder.AppendLine($"{Version.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schedule), out propertyOverride); if (Optional.IsDefined(Schedule) || hasPropertyOverride) { - builder.Append(" schedule:"); + builder.Append(" schedule: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Schedule, options, 4, false); + AppendChildObject(builder, Schedule, options, 4, false, " schedule: "); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobExecutionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobExecutionData.Serialization.cs index 85c86210ffba8..82514269a09e7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobExecutionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobExecutionData.Serialization.cs @@ -316,7 +316,7 @@ internal static SqlServerJobExecutionData DeserializeSqlServerJobExecutionData(J { continue; } - target = JobExecutionTarget.DeserializeJobExecutionTarget(property0.Value, options); + target = JobExecutionTarget.DeserializeJobExecutionTarget(property0.Value); continue; } } @@ -345,21 +345,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -367,28 +367,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -397,35 +397,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JobVersion), out propertyOverride); if (Optional.IsDefined(JobVersion) || hasPropertyOverride) { - builder.Append(" jobVersion:"); + builder.Append(" jobVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {JobVersion.Value}"); + builder.AppendLine($"{JobVersion.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StepName), out propertyOverride); if (Optional.IsDefined(StepName) || hasPropertyOverride) { - builder.Append(" stepName:"); + builder.Append(" stepName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StepName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StepName}'''"); } else { - builder.AppendLine($" '{StepName}'"); + builder.AppendLine($"'{StepName}'"); } } } @@ -433,151 +433,151 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StepId), out propertyOverride); if (Optional.IsDefined(StepId) || hasPropertyOverride) { - builder.Append(" stepId:"); + builder.Append(" stepId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StepId.Value}"); + builder.AppendLine($"{StepId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JobExecutionId), out propertyOverride); if (Optional.IsDefined(JobExecutionId) || hasPropertyOverride) { - builder.Append(" jobExecutionId:"); + builder.Append(" jobExecutionId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{JobExecutionId.Value.ToString()}'"); + builder.AppendLine($"'{JobExecutionId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Lifecycle), out propertyOverride); if (Optional.IsDefined(Lifecycle) || hasPropertyOverride) { - builder.Append(" lifecycle:"); + builder.Append(" lifecycle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Lifecycle.Value.ToString()}'"); + builder.AppendLine($"'{Lifecycle.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateOn), out propertyOverride); if (Optional.IsDefined(CreateOn) || hasPropertyOverride) { - builder.Append(" createTime:"); + builder.Append(" createTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreateOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentAttempts), out propertyOverride); if (Optional.IsDefined(CurrentAttempts) || hasPropertyOverride) { - builder.Append(" currentAttempts:"); + builder.Append(" currentAttempts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentAttempts.Value}"); + builder.AppendLine($"{CurrentAttempts.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentAttemptStartOn), out propertyOverride); if (Optional.IsDefined(CurrentAttemptStartOn) || hasPropertyOverride) { - builder.Append(" currentAttemptStartTime:"); + builder.Append(" currentAttemptStartTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CurrentAttemptStartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastMessage), out propertyOverride); if (Optional.IsDefined(LastMessage) || hasPropertyOverride) { - builder.Append(" lastMessage:"); + builder.Append(" lastMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LastMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LastMessage}'''"); } else { - builder.AppendLine($" '{LastMessage}'"); + builder.AppendLine($"'{LastMessage}'"); } } } @@ -585,14 +585,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); if (Optional.IsDefined(Target) || hasPropertyOverride) { - builder.Append(" target:"); + builder.Append(" target: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Target, options, 4, false); + AppendChildObject(builder, Target, options, 4, false, " target: "); } } @@ -601,12 +601,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -627,13 +630,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobStepData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobStepData.Serialization.cs index 2d1bfa5eb80e6..e7d0a647f48f7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobStepData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobStepData.Serialization.cs @@ -193,7 +193,7 @@ internal static SqlServerJobStepData DeserializeSqlServerJobStepData(JsonElement { continue; } - action = JobStepAction.DeserializeJobStepAction(property0.Value, options); + action = JobStepAction.DeserializeJobStepAction(property0.Value); continue; } if (property0.NameEquals("output"u8)) @@ -202,7 +202,7 @@ internal static SqlServerJobStepData DeserializeSqlServerJobStepData(JsonElement { continue; } - output = JobStepOutput.DeserializeJobStepOutput(property0.Value, options); + output = JobStepOutput.DeserializeJobStepOutput(property0.Value); continue; } if (property0.NameEquals("executionOptions"u8)) @@ -211,7 +211,7 @@ internal static SqlServerJobStepData DeserializeSqlServerJobStepData(JsonElement { continue; } - executionOptions = JobStepExecutionOptions.DeserializeJobStepExecutionOptions(property0.Value, options); + executionOptions = JobStepExecutionOptions.DeserializeJobStepExecutionOptions(property0.Value); continue; } } @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -262,28 +262,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -292,35 +292,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StepId), out propertyOverride); if (Optional.IsDefined(StepId) || hasPropertyOverride) { - builder.Append(" stepId:"); + builder.Append(" stepId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {StepId.Value}"); + builder.AppendLine($"{StepId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetGroup), out propertyOverride); if (Optional.IsDefined(TargetGroup) || hasPropertyOverride) { - builder.Append(" targetGroup:"); + builder.Append(" targetGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TargetGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TargetGroup}'''"); } else { - builder.AppendLine($" '{TargetGroup}'"); + builder.AppendLine($"'{TargetGroup}'"); } } } @@ -328,21 +328,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credential), out propertyOverride); if (Optional.IsDefined(Credential) || hasPropertyOverride) { - builder.Append(" credential:"); + builder.Append(" credential: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Credential.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Credential}'''"); } else { - builder.AppendLine($" '{Credential}'"); + builder.AppendLine($"'{Credential}'"); } } } @@ -350,42 +350,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); if (Optional.IsDefined(Action) || hasPropertyOverride) { - builder.Append(" action:"); + builder.Append(" action: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Action, options, 4, false); + AppendChildObject(builder, Action, options, 4, false, " action: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Output), out propertyOverride); if (Optional.IsDefined(Output) || hasPropertyOverride) { - builder.Append(" output:"); + builder.Append(" output: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Output, options, 4, false); + AppendChildObject(builder, Output, options, 4, false, " output: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecutionOptions), out propertyOverride); if (Optional.IsDefined(ExecutionOptions) || hasPropertyOverride) { - builder.Append(" executionOptions:"); + builder.Append(" executionOptions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExecutionOptions, options, 4, false); + AppendChildObject(builder, ExecutionOptions, options, 4, false, " executionOptions: "); } } @@ -394,12 +394,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -420,13 +423,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobTargetGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobTargetGroupData.Serialization.cs index c32fd881275ca..e287faedd20ab 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobTargetGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobTargetGroupData.Serialization.cs @@ -153,7 +153,7 @@ internal static SqlServerJobTargetGroupData DeserializeSqlServerJobTargetGroupDa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JobTarget.DeserializeJobTarget(item, options)); + array.Add(JobTarget.DeserializeJobTarget(item)); } members = array; continue; @@ -184,21 +184,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -206,28 +206,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -238,17 +238,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Members.Any() || hasPropertyOverride) { - builder.Append(" members:"); + builder.Append(" members: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Members) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " members: "); } builder.AppendLine(" ]"); } @@ -260,12 +260,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -286,13 +289,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobVersionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobVersionData.Serialization.cs index 3e6a056919bdd..5b39ce4227783 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobVersionData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerJobVersionData.Serialization.cs @@ -142,21 +142,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -164,28 +164,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerKeyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerKeyData.Serialization.cs index 6703f1e2700fd..9fba066d058f1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerKeyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerKeyData.Serialization.cs @@ -266,21 +266,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -288,35 +288,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -324,28 +324,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -354,21 +354,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subregion), out propertyOverride); if (Optional.IsDefined(Subregion) || hasPropertyOverride) { - builder.Append(" subregion:"); + builder.Append(" subregion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subregion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subregion}'''"); } else { - builder.AppendLine($" '{Subregion}'"); + builder.AppendLine($"'{Subregion}'"); } } } @@ -376,49 +376,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyType), out propertyOverride); if (Optional.IsDefined(ServerKeyType) || hasPropertyOverride) { - builder.Append(" serverKeyType:"); + builder.Append(" serverKeyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerKeyType.Value.ToString()}'"); + builder.AppendLine($"'{ServerKeyType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" uri:"); + builder.Append(" uri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Thumbprint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Thumbprint}'''"); } else { - builder.AppendLine($" '{Thumbprint}'"); + builder.AppendLine($"'{Thumbprint}'"); } } } @@ -426,30 +426,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationDate:"); + builder.Append(" creationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRotationEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoRotationEnabled) || hasPropertyOverride) { - builder.Append(" autoRotationEnabled:"); + builder.Append(" autoRotationEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRotationEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -458,12 +458,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -484,13 +487,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerSecurityAlertPolicyData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerSecurityAlertPolicyData.Serialization.cs index a5785f296e88d..bb721ac6104a5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerSecurityAlertPolicyData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerSecurityAlertPolicyData.Serialization.cs @@ -291,21 +291,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -313,28 +313,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -343,14 +343,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -359,14 +359,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DisabledAlerts.Any() || hasPropertyOverride) { - builder.Append(" disabledAlerts:"); + builder.Append(" disabledAlerts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DisabledAlerts) { if (item == null) @@ -394,14 +394,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EmailAddresses.Any() || hasPropertyOverride) { - builder.Append(" emailAddresses:"); + builder.Append(" emailAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EmailAddresses) { if (item == null) @@ -427,36 +427,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendToEmailAccountAdmins), out propertyOverride); if (Optional.IsDefined(SendToEmailAccountAdmins) || hasPropertyOverride) { - builder.Append(" emailAccountAdmins:"); + builder.Append(" emailAccountAdmins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SendToEmailAccountAdmins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) { - builder.Append(" storageEndpoint:"); + builder.Append(" storageEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageEndpoint}'''"); } else { - builder.AppendLine($" '{StorageEndpoint}'"); + builder.AppendLine($"'{StorageEndpoint}'"); } } } @@ -464,21 +464,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -486,29 +486,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) { - builder.Append(" retentionDays:"); + builder.Append(" retentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionDays.Value}"); + builder.AppendLine($"{RetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -517,12 +517,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -543,13 +546,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerTrustGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerTrustGroupData.Serialization.cs index 002079d4cfe22..8357530ec23a3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerTrustGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerTrustGroupData.Serialization.cs @@ -164,7 +164,7 @@ internal static SqlServerTrustGroupData DeserializeSqlServerTrustGroupData(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ServerTrustGroupServerInfo.DeserializeServerTrustGroupServerInfo(item, options)); + array.Add(ServerTrustGroupServerInfo.DeserializeServerTrustGroupServerInfo(item)); } groupMembers = array; continue; @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,28 +231,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -263,17 +263,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GroupMembers.Any() || hasPropertyOverride) { - builder.Append(" groupMembers:"); + builder.Append(" groupMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GroupMembers) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " groupMembers: "); } builder.AppendLine(" ]"); } @@ -285,14 +285,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TrustScopes.Any() || hasPropertyOverride) { - builder.Append(" trustScopes:"); + builder.Append(" trustScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TrustScopes) { builder.AppendLine($" '{item.ToString()}'"); @@ -307,12 +307,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -333,13 +336,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVirtualNetworkRuleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVirtualNetworkRuleData.Serialization.cs index 32a1152470581..7368383fadc82 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVirtualNetworkRuleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVirtualNetworkRuleData.Serialization.cs @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,28 +225,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -255,43 +255,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkSubnetId), out propertyOverride); if (Optional.IsDefined(VirtualNetworkSubnetId) || hasPropertyOverride) { - builder.Append(" virtualNetworkSubnetId:"); + builder.Append(" virtualNetworkSubnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VirtualNetworkSubnetId.ToString()}'"); + builder.AppendLine($"'{VirtualNetworkSubnetId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreMissingVnetServiceEndpoint), out propertyOverride); if (Optional.IsDefined(IgnoreMissingVnetServiceEndpoint) || hasPropertyOverride) { - builder.Append(" ignoreMissingVnetServiceEndpoint:"); + builder.Append(" ignoreMissingVnetServiceEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IgnoreMissingVnetServiceEndpoint.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } @@ -300,12 +300,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -326,13 +329,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVulnerabilityAssessmentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVulnerabilityAssessmentData.Serialization.cs index e75528ee7f4c4..ae5552dfe62ea 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVulnerabilityAssessmentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerVulnerabilityAssessmentData.Serialization.cs @@ -177,7 +177,7 @@ internal static SqlServerVulnerabilityAssessmentData DeserializeSqlServerVulnera { continue; } - recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value, options); + recurringScans = VulnerabilityAssessmentRecurringScansProperties.DeserializeVulnerabilityAssessmentRecurringScansProperties(property0.Value); continue; } } @@ -206,21 +206,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -228,28 +228,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerPath), out propertyOverride); if (Optional.IsDefined(StorageContainerPath) || hasPropertyOverride) { - builder.Append(" storageContainerPath:"); + builder.Append(" storageContainerPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerPath}'''"); } else { - builder.AppendLine($" '{StorageContainerPath}'"); + builder.AppendLine($"'{StorageContainerPath}'"); } } } @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerSasKey), out propertyOverride); if (Optional.IsDefined(StorageContainerSasKey) || hasPropertyOverride) { - builder.Append(" storageContainerSasKey:"); + builder.Append(" storageContainerSasKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerSasKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerSasKey}'''"); } else { - builder.AppendLine($" '{StorageContainerSasKey}'"); + builder.AppendLine($"'{StorageContainerSasKey}'"); } } } @@ -302,21 +302,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) { - builder.Append(" storageAccountAccessKey:"); + builder.Append(" storageAccountAccessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageAccountAccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageAccountAccessKey}'''"); } else { - builder.AppendLine($" '{StorageAccountAccessKey}'"); + builder.AppendLine($"'{StorageAccountAccessKey}'"); } } } @@ -324,14 +324,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecurringScans), out propertyOverride); if (Optional.IsDefined(RecurringScans) || hasPropertyOverride) { - builder.Append(" recurringScans:"); + builder.Append(" recurringScans: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RecurringScans, options, 4, false); + AppendChildObject(builder, RecurringScans, options, 4, false, " recurringScans: "); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlTimeZoneData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlTimeZoneData.Serialization.cs index ce386f0c43367..9512f30a0a039 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlTimeZoneData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlTimeZoneData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,28 +201,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeZoneId), out propertyOverride); if (Optional.IsDefined(TimeZoneId) || hasPropertyOverride) { - builder.Append(" timeZoneId:"); + builder.Append(" timeZoneId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeZoneId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeZoneId}'''"); } else { - builder.AppendLine($" '{TimeZoneId}'"); + builder.AppendLine($"'{TimeZoneId}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineData.Serialization.cs index 186cbfe74b5d8..80729ea7f21e1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineData.Serialization.cs @@ -228,21 +228,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -250,28 +250,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -282,23 +282,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Results.Any() || hasPropertyOverride) { - builder.Append(" results:"); + builder.Append(" results: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Results) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item.Value) { if (item0 == null) @@ -306,7 +306,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item1 in item0) { if (item1 == null) @@ -338,12 +338,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -364,13 +367,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineRuleData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineRuleData.Serialization.cs index 3d98dde842dd2..213ba44df4e6d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineRuleData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentBaselineRuleData.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -259,14 +259,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Results.Any() || hasPropertyOverride) { - builder.Append(" results:"); + builder.Append(" results: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Results) { if (item == null) @@ -274,7 +274,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -304,12 +304,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -330,13 +333,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentData.Serialization.cs index 4154038586e3e..8a10da738c416 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentData.Serialization.cs @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanData.Serialization.cs index ffd2def6b634a..0a552d536c905 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanData.Serialization.cs @@ -290,7 +290,7 @@ internal static SqlVulnerabilityAssessmentScanData DeserializeSqlVulnerabilityAs List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SqlVulnerabilityAssessmentScanError.DeserializeSqlVulnerabilityAssessmentScanError(item, options)); + array.Add(SqlVulnerabilityAssessmentScanError.DeserializeSqlVulnerabilityAssessmentScanError(item)); } errors = array; continue; @@ -408,21 +408,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -430,28 +430,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -460,21 +460,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScanId), out propertyOverride); if (Optional.IsDefined(ScanId) || hasPropertyOverride) { - builder.Append(" scanId:"); + builder.Append(" scanId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScanId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScanId}'''"); } else { - builder.AppendLine($" '{ScanId}'"); + builder.AppendLine($"'{ScanId}'"); } } } @@ -482,58 +482,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerType), out propertyOverride); if (Optional.IsDefined(TriggerType) || hasPropertyOverride) { - builder.Append(" triggerType:"); + builder.Append(" triggerType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TriggerType.Value.ToString()}'"); + builder.AppendLine($"'{TriggerType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -542,17 +542,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Errors.Any() || hasPropertyOverride) { - builder.Append(" errors:"); + builder.Append(" errors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Errors) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " errors: "); } builder.AppendLine(" ]"); } @@ -562,21 +562,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Server), out propertyOverride); if (Optional.IsDefined(Server) || hasPropertyOverride) { - builder.Append(" server:"); + builder.Append(" server: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Server.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Server}'''"); } else { - builder.AppendLine($" '{Server}'"); + builder.AppendLine($"'{Server}'"); } } } @@ -584,21 +584,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Database), out propertyOverride); if (Optional.IsDefined(Database) || hasPropertyOverride) { - builder.Append(" database:"); + builder.Append(" database: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Database.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Database}'''"); } else { - builder.AppendLine($" '{Database}'"); + builder.AppendLine($"'{Database}'"); } } } @@ -606,21 +606,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SqlVersion), out propertyOverride); if (Optional.IsDefined(SqlVersion) || hasPropertyOverride) { - builder.Append(" sqlVersion:"); + builder.Append(" sqlVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SqlVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SqlVersion}'''"); } else { - builder.AppendLine($" '{SqlVersion}'"); + builder.AppendLine($"'{SqlVersion}'"); } } } @@ -628,114 +628,114 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HighSeverityFailedRulesCount), out propertyOverride); if (Optional.IsDefined(HighSeverityFailedRulesCount) || hasPropertyOverride) { - builder.Append(" highSeverityFailedRulesCount:"); + builder.Append(" highSeverityFailedRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {HighSeverityFailedRulesCount.Value}"); + builder.AppendLine($"{HighSeverityFailedRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MediumSeverityFailedRulesCount), out propertyOverride); if (Optional.IsDefined(MediumSeverityFailedRulesCount) || hasPropertyOverride) { - builder.Append(" mediumSeverityFailedRulesCount:"); + builder.Append(" mediumSeverityFailedRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MediumSeverityFailedRulesCount.Value}"); + builder.AppendLine($"{MediumSeverityFailedRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LowSeverityFailedRulesCount), out propertyOverride); if (Optional.IsDefined(LowSeverityFailedRulesCount) || hasPropertyOverride) { - builder.Append(" lowSeverityFailedRulesCount:"); + builder.Append(" lowSeverityFailedRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {LowSeverityFailedRulesCount.Value}"); + builder.AppendLine($"{LowSeverityFailedRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalPassedRulesCount), out propertyOverride); if (Optional.IsDefined(TotalPassedRulesCount) || hasPropertyOverride) { - builder.Append(" totalPassedRulesCount:"); + builder.Append(" totalPassedRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TotalPassedRulesCount.Value}"); + builder.AppendLine($"{TotalPassedRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalFailedRulesCount), out propertyOverride); if (Optional.IsDefined(TotalFailedRulesCount) || hasPropertyOverride) { - builder.Append(" totalFailedRulesCount:"); + builder.Append(" totalFailedRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TotalFailedRulesCount.Value}"); + builder.AppendLine($"{TotalFailedRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalRulesCount), out propertyOverride); if (Optional.IsDefined(TotalRulesCount) || hasPropertyOverride) { - builder.Append(" totalRulesCount:"); + builder.Append(" totalRulesCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TotalRulesCount.Value}"); + builder.AppendLine($"{TotalRulesCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsBaselineApplied), out propertyOverride); if (Optional.IsDefined(IsBaselineApplied) || hasPropertyOverride) { - builder.Append(" isBaselineApplied:"); + builder.Append(" isBaselineApplied: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsBaselineApplied.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastScanOn), out propertyOverride); if (Optional.IsDefined(LastScanOn) || hasPropertyOverride) { - builder.Append(" lastScanTime:"); + builder.Append(" lastScanTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastScanOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -744,12 +744,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -770,13 +773,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanResultData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanResultData.Serialization.cs index 7a899622ccce1..3ee9292289e47 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanResultData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlVulnerabilityAssessmentScanResultData.Serialization.cs @@ -256,7 +256,7 @@ internal static SqlVulnerabilityAssessmentScanResultData DeserializeSqlVulnerabi { continue; } - remediation = SqlVulnerabilityAssessmentRemediation.DeserializeSqlVulnerabilityAssessmentRemediation(property0.Value, options); + remediation = SqlVulnerabilityAssessmentRemediation.DeserializeSqlVulnerabilityAssessmentRemediation(property0.Value); continue; } if (property0.NameEquals("baselineAdjustedResult"u8)) @@ -265,7 +265,7 @@ internal static SqlVulnerabilityAssessmentScanResultData DeserializeSqlVulnerabi { continue; } - baselineAdjustedResult = SqlVulnerabilityAssessmentBaselineAdjustedResult.DeserializeSqlVulnerabilityAssessmentBaselineAdjustedResult(property0.Value, options); + baselineAdjustedResult = SqlVulnerabilityAssessmentBaselineAdjustedResult.DeserializeSqlVulnerabilityAssessmentBaselineAdjustedResult(property0.Value); continue; } if (property0.NameEquals("ruleMetadata"u8)) @@ -274,7 +274,7 @@ internal static SqlVulnerabilityAssessmentScanResultData DeserializeSqlVulnerabi { continue; } - ruleMetadata = SqlVulnerabilityAssessmentRuleMetadata.DeserializeSqlVulnerabilityAssessmentRuleMetadata(property0.Value, options); + ruleMetadata = SqlVulnerabilityAssessmentRuleMetadata.DeserializeSqlVulnerabilityAssessmentRuleMetadata(property0.Value); continue; } } @@ -303,21 +303,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -325,28 +325,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -355,21 +355,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleId), out propertyOverride); if (Optional.IsDefined(RuleId) || hasPropertyOverride) { - builder.Append(" ruleId:"); + builder.Append(" ruleId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuleId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuleId}'''"); } else { - builder.AppendLine($" '{RuleId}'"); + builder.AppendLine($"'{RuleId}'"); } } } @@ -377,35 +377,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -413,15 +413,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsTrimmed), out propertyOverride); if (Optional.IsDefined(IsTrimmed) || hasPropertyOverride) { - builder.Append(" isTrimmed:"); + builder.Append(" isTrimmed: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsTrimmed.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -430,14 +430,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (QueryResults.Any() || hasPropertyOverride) { - builder.Append(" queryResults:"); + builder.Append(" queryResults: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in QueryResults) { if (item == null) @@ -445,7 +445,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -473,42 +473,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Remediation), out propertyOverride); if (Optional.IsDefined(Remediation) || hasPropertyOverride) { - builder.Append(" remediation:"); + builder.Append(" remediation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Remediation, options, 4, false); + AppendChildObject(builder, Remediation, options, 4, false, " remediation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaselineAdjustedResult), out propertyOverride); if (Optional.IsDefined(BaselineAdjustedResult) || hasPropertyOverride) { - builder.Append(" baselineAdjustedResult:"); + builder.Append(" baselineAdjustedResult: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BaselineAdjustedResult, options, 4, false); + AppendChildObject(builder, BaselineAdjustedResult, options, 4, false, " baselineAdjustedResult: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleMetadata), out propertyOverride); if (Optional.IsDefined(RuleMetadata) || hasPropertyOverride) { - builder.Append(" ruleMetadata:"); + builder.Append(" ruleMetadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RuleMetadata, options, 4, false); + AppendChildObject(builder, RuleMetadata, options, 4, false, " ruleMetadata: "); } } @@ -517,12 +517,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -543,13 +546,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SubscriptionUsageData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SubscriptionUsageData.Serialization.cs index 4fae0d58c3358..5a0204d52f81b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SubscriptionUsageData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SubscriptionUsageData.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,28 +231,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -261,21 +261,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -283,49 +283,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.Value.ToString()}'"); + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncAgentData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncAgentData.Serialization.cs index 5261817673339..d1f3c74f3654f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncAgentData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncAgentData.Serialization.cs @@ -244,21 +244,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -266,28 +266,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -296,94 +296,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncDatabaseId), out propertyOverride); if (Optional.IsDefined(SyncDatabaseId) || hasPropertyOverride) { - builder.Append(" syncDatabaseId:"); + builder.Append(" syncDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncDatabaseId.ToString()}'"); + builder.AppendLine($"'{SyncDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastAliveOn), out propertyOverride); if (Optional.IsDefined(LastAliveOn) || hasPropertyOverride) { - builder.Append(" lastAliveTime:"); + builder.Append(" lastAliveTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastAliveOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUpToDate), out propertyOverride); if (Optional.IsDefined(IsUpToDate) || hasPropertyOverride) { - builder.Append(" isUpToDate:"); + builder.Append(" isUpToDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUpToDate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expiryTime:"); + builder.Append(" expiryTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -393,12 +393,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -419,13 +422,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncGroupData.Serialization.cs index df2d9ae686d1a..a707c2ed07eec 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncGroupData.Serialization.cs @@ -183,7 +183,7 @@ internal static SyncGroupData DeserializeSyncGroupData(JsonElement element, Mode { continue; } - sku = SqlSku.DeserializeSqlSku(property.Value, options); + sku = SqlSku.DeserializeSqlSku(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -280,7 +280,7 @@ internal static SyncGroupData DeserializeSyncGroupData(JsonElement element, Mode { continue; } - schema = SyncGroupSchema.DeserializeSyncGroupSchema(property0.Value, options); + schema = SyncGroupSchema.DeserializeSyncGroupSchema(property0.Value); continue; } if (property0.NameEquals("enableConflictLogging"u8)) @@ -341,21 +341,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -363,42 +363,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -407,78 +407,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Interval), out propertyOverride); if (Optional.IsDefined(Interval) || hasPropertyOverride) { - builder.Append(" interval:"); + builder.Append(" interval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Interval.Value}"); + builder.AppendLine($"{Interval.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastSyncOn), out propertyOverride); if (Optional.IsDefined(LastSyncOn) || hasPropertyOverride) { - builder.Append(" lastSyncTime:"); + builder.Append(" lastSyncTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastSyncOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConflictResolutionPolicy), out propertyOverride); if (Optional.IsDefined(ConflictResolutionPolicy) || hasPropertyOverride) { - builder.Append(" conflictResolutionPolicy:"); + builder.Append(" conflictResolutionPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ConflictResolutionPolicy.Value.ToString()}'"); + builder.AppendLine($"'{ConflictResolutionPolicy.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncDatabaseId), out propertyOverride); if (Optional.IsDefined(SyncDatabaseId) || hasPropertyOverride) { - builder.Append(" syncDatabaseId:"); + builder.Append(" syncDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncDatabaseId.ToString()}'"); + builder.AppendLine($"'{SyncDatabaseId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HubDatabaseUserName), out propertyOverride); if (Optional.IsDefined(HubDatabaseUserName) || hasPropertyOverride) { - builder.Append(" hubDatabaseUserName:"); + builder.Append(" hubDatabaseUserName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HubDatabaseUserName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HubDatabaseUserName}'''"); } else { - builder.AppendLine($" '{HubDatabaseUserName}'"); + builder.AppendLine($"'{HubDatabaseUserName}'"); } } } @@ -486,21 +486,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HubDatabasePassword), out propertyOverride); if (Optional.IsDefined(HubDatabasePassword) || hasPropertyOverride) { - builder.Append(" hubDatabasePassword:"); + builder.Append(" hubDatabasePassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HubDatabasePassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HubDatabasePassword}'''"); } else { - builder.AppendLine($" '{HubDatabasePassword}'"); + builder.AppendLine($"'{HubDatabasePassword}'"); } } } @@ -508,93 +508,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncState), out propertyOverride); if (Optional.IsDefined(SyncState) || hasPropertyOverride) { - builder.Append(" syncState:"); + builder.Append(" syncState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncState.Value.ToString()}'"); + builder.AppendLine($"'{SyncState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schema), out propertyOverride); if (Optional.IsDefined(Schema) || hasPropertyOverride) { - builder.Append(" schema:"); + builder.Append(" schema: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Schema, options, 4, false); + AppendChildObject(builder, Schema, options, 4, false, " schema: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsConflictLoggingEnabled), out propertyOverride); if (Optional.IsDefined(IsConflictLoggingEnabled) || hasPropertyOverride) { - builder.Append(" enableConflictLogging:"); + builder.Append(" enableConflictLogging: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsConflictLoggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConflictLoggingRetentionInDays), out propertyOverride); if (Optional.IsDefined(ConflictLoggingRetentionInDays) || hasPropertyOverride) { - builder.Append(" conflictLoggingRetentionInDays:"); + builder.Append(" conflictLoggingRetentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ConflictLoggingRetentionInDays.Value}"); + builder.AppendLine($"{ConflictLoggingRetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UsePrivateLinkConnection), out propertyOverride); if (Optional.IsDefined(UsePrivateLinkConnection) || hasPropertyOverride) { - builder.Append(" usePrivateLinkConnection:"); + builder.Append(" usePrivateLinkConnection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UsePrivateLinkConnection.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointName), out propertyOverride); if (Optional.IsDefined(PrivateEndpointName) || hasPropertyOverride) { - builder.Append(" privateEndpointName:"); + builder.Append(" privateEndpointName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrivateEndpointName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrivateEndpointName}'''"); } else { - builder.AppendLine($" '{PrivateEndpointName}'"); + builder.AppendLine($"'{PrivateEndpointName}'"); } } } @@ -604,12 +604,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -630,13 +633,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncMemberData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncMemberData.Serialization.cs index fb7c97b55612f..4bda50850bc60 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncMemberData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SyncMemberData.Serialization.cs @@ -318,21 +318,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -340,28 +340,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -370,92 +370,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseType), out propertyOverride); if (Optional.IsDefined(DatabaseType) || hasPropertyOverride) { - builder.Append(" databaseType:"); + builder.Append(" databaseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseType.Value.ToString()}'"); + builder.AppendLine($"'{DatabaseType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncAgentId), out propertyOverride); if (Optional.IsDefined(SyncAgentId) || hasPropertyOverride) { - builder.Append(" syncAgentId:"); + builder.Append(" syncAgentId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncAgentId.ToString()}'"); + builder.AppendLine($"'{SyncAgentId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SqlServerDatabaseId), out propertyOverride); if (Optional.IsDefined(SqlServerDatabaseId) || hasPropertyOverride) { - builder.Append(" sqlServerDatabaseId:"); + builder.Append(" sqlServerDatabaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SqlServerDatabaseId.Value.ToString()}'"); + builder.AppendLine($"'{SqlServerDatabaseId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncMemberAzureDatabaseResourceId), out propertyOverride); if (Optional.IsDefined(SyncMemberAzureDatabaseResourceId) || hasPropertyOverride) { - builder.Append(" syncMemberAzureDatabaseResourceId:"); + builder.Append(" syncMemberAzureDatabaseResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncMemberAzureDatabaseResourceId.ToString()}'"); + builder.AppendLine($"'{SyncMemberAzureDatabaseResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UsePrivateLinkConnection), out propertyOverride); if (Optional.IsDefined(UsePrivateLinkConnection) || hasPropertyOverride) { - builder.Append(" usePrivateLinkConnection:"); + builder.Append(" usePrivateLinkConnection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UsePrivateLinkConnection.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointName), out propertyOverride); if (Optional.IsDefined(PrivateEndpointName) || hasPropertyOverride) { - builder.Append(" privateEndpointName:"); + builder.Append(" privateEndpointName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrivateEndpointName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrivateEndpointName}'''"); } else { - builder.AppendLine($" '{PrivateEndpointName}'"); + builder.AppendLine($"'{PrivateEndpointName}'"); } } } @@ -463,21 +463,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerName), out propertyOverride); if (Optional.IsDefined(ServerName) || hasPropertyOverride) { - builder.Append(" serverName:"); + builder.Append(" serverName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServerName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServerName}'''"); } else { - builder.AppendLine($" '{ServerName}'"); + builder.AppendLine($"'{ServerName}'"); } } } @@ -485,21 +485,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) { - builder.Append(" databaseName:"); + builder.Append(" databaseName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DatabaseName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DatabaseName}'''"); } else { - builder.AppendLine($" '{DatabaseName}'"); + builder.AppendLine($"'{DatabaseName}'"); } } } @@ -507,21 +507,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserName), out propertyOverride); if (Optional.IsDefined(UserName) || hasPropertyOverride) { - builder.Append(" userName:"); + builder.Append(" userName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserName}'''"); } else { - builder.AppendLine($" '{UserName}'"); + builder.AppendLine($"'{UserName}'"); } } } @@ -529,21 +529,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); if (Optional.IsDefined(Password) || hasPropertyOverride) { - builder.Append(" password:"); + builder.Append(" password: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Password.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Password}'''"); } else { - builder.AppendLine($" '{Password}'"); + builder.AppendLine($"'{Password}'"); } } } @@ -551,28 +551,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncDirection), out propertyOverride); if (Optional.IsDefined(SyncDirection) || hasPropertyOverride) { - builder.Append(" syncDirection:"); + builder.Append(" syncDirection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncDirection.Value.ToString()}'"); + builder.AppendLine($"'{SyncDirection.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SyncState), out propertyOverride); if (Optional.IsDefined(SyncState) || hasPropertyOverride) { - builder.Append(" syncState:"); + builder.Append(" syncState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SyncState.Value.ToString()}'"); + builder.AppendLine($"'{SyncState.Value.ToString()}'"); } } @@ -581,12 +581,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -607,13 +610,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VirtualClusterData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VirtualClusterData.Serialization.cs index 87dd33c8b48e6..78320cb33c7c5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VirtualClusterData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VirtualClusterData.Serialization.cs @@ -243,21 +243,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -265,14 +265,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -281,17 +281,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -299,12 +299,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -315,28 +315,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -345,35 +345,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetId), out propertyOverride); if (Optional.IsDefined(SubnetId) || hasPropertyOverride) { - builder.Append(" subnetId:"); + builder.Append(" subnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetId.ToString()}'"); + builder.AppendLine($"'{SubnetId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -383,14 +383,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ChildResources.Any() || hasPropertyOverride) { - builder.Append(" childResources:"); + builder.Append(" childResources: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ChildResources) { if (item == null) @@ -418,12 +418,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -444,13 +447,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VulnerabilityAssessmentScanRecordData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VulnerabilityAssessmentScanRecordData.Serialization.cs index be250296614f6..cbf5707f78e6e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VulnerabilityAssessmentScanRecordData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/VulnerabilityAssessmentScanRecordData.Serialization.cs @@ -236,7 +236,7 @@ internal static VulnerabilityAssessmentScanRecordData DeserializeVulnerabilityAs List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(VulnerabilityAssessmentScanError.DeserializeVulnerabilityAssessmentScanError(item, options)); + array.Add(VulnerabilityAssessmentScanError.DeserializeVulnerabilityAssessmentScanError(item)); } errors = array; continue; @@ -281,21 +281,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -303,28 +303,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -333,21 +333,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScanId), out propertyOverride); if (Optional.IsDefined(ScanId) || hasPropertyOverride) { - builder.Append(" scanId:"); + builder.Append(" scanId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScanId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScanId}'''"); } else { - builder.AppendLine($" '{ScanId}'"); + builder.AppendLine($"'{ScanId}'"); } } } @@ -355,58 +355,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerType), out propertyOverride); if (Optional.IsDefined(TriggerType) || hasPropertyOverride) { - builder.Append(" triggerType:"); + builder.Append(" triggerType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TriggerType.Value.ToString()}'"); + builder.AppendLine($"'{TriggerType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -415,17 +415,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Errors.Any() || hasPropertyOverride) { - builder.Append(" errors:"); + builder.Append(" errors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Errors) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " errors: "); } builder.AppendLine(" ]"); } @@ -435,21 +435,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageContainerPath), out propertyOverride); if (Optional.IsDefined(StorageContainerPath) || hasPropertyOverride) { - builder.Append(" storageContainerPath:"); + builder.Append(" storageContainerPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StorageContainerPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StorageContainerPath}'''"); } else { - builder.AppendLine($" '{StorageContainerPath}'"); + builder.AppendLine($"'{StorageContainerPath}'"); } } } @@ -457,14 +457,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfFailedSecurityChecks), out propertyOverride); if (Optional.IsDefined(NumberOfFailedSecurityChecks) || hasPropertyOverride) { - builder.Append(" numberOfFailedSecurityChecks:"); + builder.Append(" numberOfFailedSecurityChecks: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfFailedSecurityChecks.Value}"); + builder.AppendLine($"{NumberOfFailedSecurityChecks.Value}"); } } @@ -473,12 +473,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -499,13 +502,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadClassifierData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadClassifierData.Serialization.cs index d806c4a9adcd9..23cbf4cd19515 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadClassifierData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadClassifierData.Serialization.cs @@ -223,21 +223,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -245,28 +245,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -275,21 +275,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MemberName), out propertyOverride); if (Optional.IsDefined(MemberName) || hasPropertyOverride) { - builder.Append(" memberName:"); + builder.Append(" memberName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MemberName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MemberName}'''"); } else { - builder.AppendLine($" '{MemberName}'"); + builder.AppendLine($"'{MemberName}'"); } } } @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Label), out propertyOverride); if (Optional.IsDefined(Label) || hasPropertyOverride) { - builder.Append(" label:"); + builder.Append(" label: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Label.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Label}'''"); } else { - builder.AppendLine($" '{Label}'"); + builder.AppendLine($"'{Label}'"); } } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Context), out propertyOverride); if (Optional.IsDefined(Context) || hasPropertyOverride) { - builder.Append(" context:"); + builder.Append(" context: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Context.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Context}'''"); } else { - builder.AppendLine($" '{Context}'"); + builder.AppendLine($"'{Context}'"); } } } @@ -341,21 +341,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartTime), out propertyOverride); if (Optional.IsDefined(StartTime) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartTime}'''"); } else { - builder.AppendLine($" '{StartTime}'"); + builder.AppendLine($"'{StartTime}'"); } } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndTime), out propertyOverride); if (Optional.IsDefined(EndTime) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndTime}'''"); } else { - builder.AppendLine($" '{EndTime}'"); + builder.AppendLine($"'{EndTime}'"); } } } @@ -385,21 +385,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Importance), out propertyOverride); if (Optional.IsDefined(Importance) || hasPropertyOverride) { - builder.Append(" importance:"); + builder.Append(" importance: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Importance.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Importance}'''"); } else { - builder.AppendLine($" '{Importance}'"); + builder.AppendLine($"'{Importance}'"); } } } @@ -409,12 +409,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -435,13 +438,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadGroupData.Serialization.cs index 9abc1537a7b6f..af1d702144f2f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadGroupData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/WorkloadGroupData.Serialization.cs @@ -243,21 +243,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -265,28 +265,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -295,77 +295,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinResourcePercent), out propertyOverride); if (Optional.IsDefined(MinResourcePercent) || hasPropertyOverride) { - builder.Append(" minResourcePercent:"); + builder.Append(" minResourcePercent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinResourcePercent.Value}"); + builder.AppendLine($"{MinResourcePercent.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxResourcePercent), out propertyOverride); if (Optional.IsDefined(MaxResourcePercent) || hasPropertyOverride) { - builder.Append(" maxResourcePercent:"); + builder.Append(" maxResourcePercent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxResourcePercent.Value}"); + builder.AppendLine($"{MaxResourcePercent.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinResourcePercentPerRequest), out propertyOverride); if (Optional.IsDefined(MinResourcePercentPerRequest) || hasPropertyOverride) { - builder.Append(" minResourcePercentPerRequest:"); + builder.Append(" minResourcePercentPerRequest: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinResourcePercentPerRequest.Value.ToString()}'"); + builder.AppendLine($"'{MinResourcePercentPerRequest.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxResourcePercentPerRequest), out propertyOverride); if (Optional.IsDefined(MaxResourcePercentPerRequest) || hasPropertyOverride) { - builder.Append(" maxResourcePercentPerRequest:"); + builder.Append(" maxResourcePercentPerRequest: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxResourcePercentPerRequest.Value.ToString()}'"); + builder.AppendLine($"'{MaxResourcePercentPerRequest.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Importance), out propertyOverride); if (Optional.IsDefined(Importance) || hasPropertyOverride) { - builder.Append(" importance:"); + builder.Append(" importance: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Importance.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Importance}'''"); } else { - builder.AppendLine($" '{Importance}'"); + builder.AppendLine($"'{Importance}'"); } } } @@ -373,14 +373,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryExecutionTimeout), out propertyOverride); if (Optional.IsDefined(QueryExecutionTimeout) || hasPropertyOverride) { - builder.Append(" queryExecutionTimeout:"); + builder.Append(" queryExecutionTimeout: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {QueryExecutionTimeout.Value}"); + builder.AppendLine($"{QueryExecutionTimeout.Value}"); } } @@ -389,12 +389,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -415,13 +418,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs index 575344e4594db..74d9f133dc9cc 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs @@ -380,7 +380,7 @@ internal static BlobContainerData DeserializeBlobContainerData(JsonElement eleme { continue; } - immutabilityPolicy = BlobContainerImmutabilityPolicy.DeserializeBlobContainerImmutabilityPolicy(property0.Value, options); + immutabilityPolicy = BlobContainerImmutabilityPolicy.DeserializeBlobContainerImmutabilityPolicy(property0.Value); continue; } if (property0.NameEquals("legalHold"u8)) @@ -389,7 +389,7 @@ internal static BlobContainerData DeserializeBlobContainerData(JsonElement eleme { continue; } - legalHold = LegalHoldProperties.DeserializeLegalHoldProperties(property0.Value, options); + legalHold = LegalHoldProperties.DeserializeLegalHoldProperties(property0.Value); continue; } if (property0.NameEquals("hasLegalHold"u8)) @@ -416,7 +416,7 @@ internal static BlobContainerData DeserializeBlobContainerData(JsonElement eleme { continue; } - immutableStorageWithVersioning = ImmutableStorageWithVersioning.DeserializeImmutableStorageWithVersioning(property0.Value, options); + immutableStorageWithVersioning = ImmutableStorageWithVersioning.DeserializeImmutableStorageWithVersioning(property0.Value); continue; } if (property0.NameEquals("enableNfsV3RootSquash"u8)) @@ -463,21 +463,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -485,42 +485,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -529,21 +529,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -551,65 +551,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeleted), out propertyOverride); if (Optional.IsDefined(IsDeleted) || hasPropertyOverride) { - builder.Append(" deleted:"); + builder.Append(" deleted: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeleted.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletedTime:"); + builder.Append(" deletedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RemainingRetentionDays), out propertyOverride); if (Optional.IsDefined(RemainingRetentionDays) || hasPropertyOverride) { - builder.Append(" remainingRetentionDays:"); + builder.Append(" remainingRetentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RemainingRetentionDays.Value}"); + builder.AppendLine($"{RemainingRetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultEncryptionScope), out propertyOverride); if (Optional.IsDefined(DefaultEncryptionScope) || hasPropertyOverride) { - builder.Append(" defaultEncryptionScope:"); + builder.Append(" defaultEncryptionScope: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultEncryptionScope.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultEncryptionScope}'''"); } else { - builder.AppendLine($" '{DefaultEncryptionScope}'"); + builder.AppendLine($"'{DefaultEncryptionScope}'"); } } } @@ -617,86 +617,86 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreventEncryptionScopeOverride), out propertyOverride); if (Optional.IsDefined(PreventEncryptionScopeOverride) || hasPropertyOverride) { - builder.Append(" denyEncryptionScopeOverride:"); + builder.Append(" denyEncryptionScopeOverride: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = PreventEncryptionScopeOverride.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicAccess), out propertyOverride); if (Optional.IsDefined(PublicAccess) || hasPropertyOverride) { - builder.Append(" publicAccess:"); + builder.Append(" publicAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicAccess.Value.ToSerialString()}'"); + builder.AppendLine($"'{PublicAccess.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseStatus), out propertyOverride); if (Optional.IsDefined(LeaseStatus) || hasPropertyOverride) { - builder.Append(" leaseStatus:"); + builder.Append(" leaseStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseStatus.Value.ToString()}'"); + builder.AppendLine($"'{LeaseStatus.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseState), out propertyOverride); if (Optional.IsDefined(LeaseState) || hasPropertyOverride) { - builder.Append(" leaseState:"); + builder.Append(" leaseState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseState.Value.ToString()}'"); + builder.AppendLine($"'{LeaseState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseDuration), out propertyOverride); if (Optional.IsDefined(LeaseDuration) || hasPropertyOverride) { - builder.Append(" leaseDuration:"); + builder.Append(" leaseDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseDuration.Value.ToString()}'"); + builder.AppendLine($"'{LeaseDuration.Value.ToString()}'"); } } @@ -705,17 +705,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metadata.Any() || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Metadata) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -723,12 +723,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -739,102 +739,102 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPolicy), out propertyOverride); if (Optional.IsDefined(ImmutabilityPolicy) || hasPropertyOverride) { - builder.Append(" immutabilityPolicy:"); + builder.Append(" immutabilityPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ImmutabilityPolicy, options, 4, false); + AppendChildObject(builder, ImmutabilityPolicy, options, 4, false, " immutabilityPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LegalHold), out propertyOverride); if (Optional.IsDefined(LegalHold) || hasPropertyOverride) { - builder.Append(" legalHold:"); + builder.Append(" legalHold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LegalHold, options, 4, false); + AppendChildObject(builder, LegalHold, options, 4, false, " legalHold: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLegalHold), out propertyOverride); if (Optional.IsDefined(HasLegalHold) || hasPropertyOverride) { - builder.Append(" hasLegalHold:"); + builder.Append(" hasLegalHold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLegalHold.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasImmutabilityPolicy), out propertyOverride); if (Optional.IsDefined(HasImmutabilityPolicy) || hasPropertyOverride) { - builder.Append(" hasImmutabilityPolicy:"); + builder.Append(" hasImmutabilityPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasImmutabilityPolicy.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutableStorageWithVersioning), out propertyOverride); if (Optional.IsDefined(ImmutableStorageWithVersioning) || hasPropertyOverride) { - builder.Append(" immutableStorageWithVersioning:"); + builder.Append(" immutableStorageWithVersioning: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ImmutableStorageWithVersioning, options, 4, false); + AppendChildObject(builder, ImmutableStorageWithVersioning, options, 4, false, " immutableStorageWithVersioning: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableNfsV3RootSquash), out propertyOverride); if (Optional.IsDefined(EnableNfsV3RootSquash) || hasPropertyOverride) { - builder.Append(" enableNfsV3RootSquash:"); + builder.Append(" enableNfsV3RootSquash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableNfsV3RootSquash.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableNfsV3AllSquash), out propertyOverride); if (Optional.IsDefined(EnableNfsV3AllSquash) || hasPropertyOverride) { - builder.Append(" enableNfsV3AllSquash:"); + builder.Append(" enableNfsV3AllSquash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableNfsV3AllSquash.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -843,12 +843,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -869,13 +872,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs index adf99201778f9..76984c586f0b1 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs @@ -159,7 +159,7 @@ internal static BlobInventoryPolicyData DeserializeBlobInventoryPolicyData(JsonE { continue; } - policy = BlobInventoryPolicySchema.DeserializeBlobInventoryPolicySchema(property0.Value, options); + policy = BlobInventoryPolicySchema.DeserializeBlobInventoryPolicySchema(property0.Value); continue; } } @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicySchema), out propertyOverride); if (Optional.IsDefined(PolicySchema) || hasPropertyOverride) { - builder.Append(" policy:"); + builder.Append(" policy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PolicySchema, options, 4, false); + AppendChildObject(builder, PolicySchema, options, 4, false, " policy: "); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs index fea0c3b6d6e73..7c0487f4e6d6f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs @@ -165,7 +165,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - sku = StorageSku.DeserializeStorageSku(property.Value, options); + sku = StorageSku.DeserializeStorageSku(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -207,7 +207,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value, options); + cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value); continue; } if (property0.NameEquals("defaultServiceVersion"u8)) @@ -221,7 +221,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - deleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value, options); + deleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value); continue; } if (property0.NameEquals("isVersioningEnabled"u8)) @@ -248,7 +248,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - changeFeed = BlobServiceChangeFeed.DeserializeBlobServiceChangeFeed(property0.Value, options); + changeFeed = BlobServiceChangeFeed.DeserializeBlobServiceChangeFeed(property0.Value); continue; } if (property0.NameEquals("restorePolicy"u8)) @@ -257,7 +257,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - restorePolicy = RestorePolicy.DeserializeRestorePolicy(property0.Value, options); + restorePolicy = RestorePolicy.DeserializeRestorePolicy(property0.Value); continue; } if (property0.NameEquals("containerDeleteRetentionPolicy"u8)) @@ -266,7 +266,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - containerDeleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value, options); + containerDeleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value); continue; } if (property0.NameEquals("lastAccessTimeTrackingPolicy"u8)) @@ -275,7 +275,7 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element, { continue; } - lastAccessTimeTrackingPolicy = LastAccessTimeTrackingPolicy.DeserializeLastAccessTimeTrackingPolicy(property0.Value, options); + lastAccessTimeTrackingPolicy = LastAccessTimeTrackingPolicy.DeserializeLastAccessTimeTrackingPolicy(property0.Value); continue; } } @@ -304,21 +304,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -326,42 +326,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -370,35 +370,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 4, false); + AppendChildObject(builder, Cors, options, 4, false, " cors: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultServiceVersion), out propertyOverride); if (Optional.IsDefined(DefaultServiceVersion) || hasPropertyOverride) { - builder.Append(" defaultServiceVersion:"); + builder.Append(" defaultServiceVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultServiceVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultServiceVersion}'''"); } else { - builder.AppendLine($" '{DefaultServiceVersion}'"); + builder.AppendLine($"'{DefaultServiceVersion}'"); } } } @@ -406,100 +406,100 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeleteRetentionPolicy), out propertyOverride); if (Optional.IsDefined(DeleteRetentionPolicy) || hasPropertyOverride) { - builder.Append(" deleteRetentionPolicy:"); + builder.Append(" deleteRetentionPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DeleteRetentionPolicy, options, 4, false); + AppendChildObject(builder, DeleteRetentionPolicy, options, 4, false, " deleteRetentionPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsVersioningEnabled), out propertyOverride); if (Optional.IsDefined(IsVersioningEnabled) || hasPropertyOverride) { - builder.Append(" isVersioningEnabled:"); + builder.Append(" isVersioningEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsVersioningEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutomaticSnapshotPolicyEnabled), out propertyOverride); if (Optional.IsDefined(IsAutomaticSnapshotPolicyEnabled) || hasPropertyOverride) { - builder.Append(" automaticSnapshotPolicyEnabled:"); + builder.Append(" automaticSnapshotPolicyEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutomaticSnapshotPolicyEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeFeed), out propertyOverride); if (Optional.IsDefined(ChangeFeed) || hasPropertyOverride) { - builder.Append(" changeFeed:"); + builder.Append(" changeFeed: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ChangeFeed, options, 4, false); + AppendChildObject(builder, ChangeFeed, options, 4, false, " changeFeed: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePolicy), out propertyOverride); if (Optional.IsDefined(RestorePolicy) || hasPropertyOverride) { - builder.Append(" restorePolicy:"); + builder.Append(" restorePolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RestorePolicy, options, 4, false); + AppendChildObject(builder, RestorePolicy, options, 4, false, " restorePolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerDeleteRetentionPolicy), out propertyOverride); if (Optional.IsDefined(ContainerDeleteRetentionPolicy) || hasPropertyOverride) { - builder.Append(" containerDeleteRetentionPolicy:"); + builder.Append(" containerDeleteRetentionPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContainerDeleteRetentionPolicy, options, 4, false); + AppendChildObject(builder, ContainerDeleteRetentionPolicy, options, 4, false, " containerDeleteRetentionPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastAccessTimeTrackingPolicy), out propertyOverride); if (Optional.IsDefined(LastAccessTimeTrackingPolicy) || hasPropertyOverride) { - builder.Append(" lastAccessTimeTrackingPolicy:"); + builder.Append(" lastAccessTimeTrackingPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LastAccessTimeTrackingPolicy, options, 4, false); + AppendChildObject(builder, LastAccessTimeTrackingPolicy, options, 4, false, " lastAccessTimeTrackingPolicy: "); } } @@ -508,12 +508,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -534,13 +537,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs index 05a50007bf8f3..44a2dcaafdccd 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs @@ -228,21 +228,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -250,28 +250,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -280,49 +280,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountResourceId), out propertyOverride); if (Optional.IsDefined(StorageAccountResourceId) || hasPropertyOverride) { - builder.Append(" storageAccountResourceId:"); + builder.Append(" storageAccountResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountResourceId.ToString()}'"); + builder.AppendLine($"'{StorageAccountResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoreReference), out propertyOverride); if (Optional.IsDefined(RestoreReference) || hasPropertyOverride) { - builder.Append(" restoreReference:"); + builder.Append(" restoreReference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RestoreReference.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RestoreReference}'''"); } else { - builder.AppendLine($" '{RestoreReference}'"); + builder.AppendLine($"'{RestoreReference}'"); } } } @@ -330,30 +330,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletionTime:"); + builder.Append(" deletionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -362,12 +362,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -388,13 +391,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs index f18d147834860..6641285afd062 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs @@ -210,7 +210,7 @@ internal static EncryptionScopeData DeserializeEncryptionScopeData(JsonElement e { continue; } - keyVaultProperties = EncryptionScopeKeyVaultProperties.DeserializeEncryptionScopeKeyVaultProperties(property0.Value, options); + keyVaultProperties = EncryptionScopeKeyVaultProperties.DeserializeEncryptionScopeKeyVaultProperties(property0.Value); continue; } if (property0.NameEquals("requireInfrastructureEncryption"u8)) @@ -248,21 +248,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -270,28 +270,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -300,87 +300,87 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Source.Value.ToString()}'"); + builder.AppendLine($"'{Source.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) { - builder.Append(" keyVaultProperties:"); + builder.Append(" keyVaultProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyVaultProperties, options, 4, false); + AppendChildObject(builder, KeyVaultProperties, options, 4, false, " keyVaultProperties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequireInfrastructureEncryption), out propertyOverride); if (Optional.IsDefined(RequireInfrastructureEncryption) || hasPropertyOverride) { - builder.Append(" requireInfrastructureEncryption:"); + builder.Append(" requireInfrastructureEncryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = RequireInfrastructureEncryption.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -389,12 +389,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -415,13 +418,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs index eed6adc5573f7..507c24ef062d4 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs @@ -129,7 +129,7 @@ internal static FileServiceData DeserializeFileServiceData(JsonElement element, { continue; } - sku = StorageSku.DeserializeStorageSku(property.Value, options); + sku = StorageSku.DeserializeStorageSku(property.Value); continue; } if (property.NameEquals("id"u8)) @@ -171,7 +171,7 @@ internal static FileServiceData DeserializeFileServiceData(JsonElement element, { continue; } - cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value, options); + cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value); continue; } if (property0.NameEquals("shareDeleteRetentionPolicy"u8)) @@ -180,7 +180,7 @@ internal static FileServiceData DeserializeFileServiceData(JsonElement element, { continue; } - shareDeleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value, options); + shareDeleteRetentionPolicy = DeleteRetentionPolicy.DeserializeDeleteRetentionPolicy(property0.Value); continue; } if (property0.NameEquals("protocolSettings"u8)) @@ -189,7 +189,7 @@ internal static FileServiceData DeserializeFileServiceData(JsonElement element, { continue; } - protocolSettings = ProtocolSettings.DeserializeProtocolSettings(property0.Value, options); + protocolSettings = ProtocolSettings.DeserializeProtocolSettings(property0.Value); continue; } } @@ -218,21 +218,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -240,42 +240,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -284,42 +284,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 4, false); + AppendChildObject(builder, Cors, options, 4, false, " cors: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShareDeleteRetentionPolicy), out propertyOverride); if (Optional.IsDefined(ShareDeleteRetentionPolicy) || hasPropertyOverride) { - builder.Append(" shareDeleteRetentionPolicy:"); + builder.Append(" shareDeleteRetentionPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ShareDeleteRetentionPolicy, options, 4, false); + AppendChildObject(builder, ShareDeleteRetentionPolicy, options, 4, false, " shareDeleteRetentionPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProtocolSettings), out propertyOverride); if (Optional.IsDefined(ProtocolSettings) || hasPropertyOverride) { - builder.Append(" protocolSettings:"); + builder.Append(" protocolSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ProtocolSettings, options, 4, false); + AppendChildObject(builder, ProtocolSettings, options, 4, false, " protocolSettings: "); } } @@ -328,12 +328,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -354,13 +357,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs index 504dad532fee7..c9cd979d40a96 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs @@ -418,7 +418,7 @@ internal static FileShareData DeserializeFileShareData(JsonElement element, Mode List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(StorageSignedIdentifier.DeserializeStorageSignedIdentifier(item, options)); + array.Add(StorageSignedIdentifier.DeserializeStorageSignedIdentifier(item)); } signedIdentifiers = array; continue; @@ -458,21 +458,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -480,42 +480,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -524,15 +524,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -541,17 +541,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metadata.Any() || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Metadata) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -559,12 +559,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -575,63 +575,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShareQuota), out propertyOverride); if (Optional.IsDefined(ShareQuota) || hasPropertyOverride) { - builder.Append(" shareQuota:"); + builder.Append(" shareQuota: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ShareQuota.Value}"); + builder.AppendLine($"{ShareQuota.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledProtocol), out propertyOverride); if (Optional.IsDefined(EnabledProtocol) || hasPropertyOverride) { - builder.Append(" enabledProtocols:"); + builder.Append(" enabledProtocols: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{EnabledProtocol.Value.ToString()}'"); + builder.AppendLine($"'{EnabledProtocol.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RootSquash), out propertyOverride); if (Optional.IsDefined(RootSquash) || hasPropertyOverride) { - builder.Append(" rootSquash:"); + builder.Append(" rootSquash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RootSquash.Value.ToString()}'"); + builder.AppendLine($"'{RootSquash.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -639,94 +639,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeleted), out propertyOverride); if (Optional.IsDefined(IsDeleted) || hasPropertyOverride) { - builder.Append(" deleted:"); + builder.Append(" deleted: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeleted.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedOn), out propertyOverride); if (Optional.IsDefined(DeletedOn) || hasPropertyOverride) { - builder.Append(" deletedTime:"); + builder.Append(" deletedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(DeletedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RemainingRetentionDays), out propertyOverride); if (Optional.IsDefined(RemainingRetentionDays) || hasPropertyOverride) { - builder.Append(" remainingRetentionDays:"); + builder.Append(" remainingRetentionDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RemainingRetentionDays.Value}"); + builder.AppendLine($"{RemainingRetentionDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessTier), out propertyOverride); if (Optional.IsDefined(AccessTier) || hasPropertyOverride) { - builder.Append(" accessTier:"); + builder.Append(" accessTier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AccessTier.Value.ToString()}'"); + builder.AppendLine($"'{AccessTier.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessTierChangeOn), out propertyOverride); if (Optional.IsDefined(AccessTierChangeOn) || hasPropertyOverride) { - builder.Append(" accessTierChangeTime:"); + builder.Append(" accessTierChangeTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(AccessTierChangeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessTierStatus), out propertyOverride); if (Optional.IsDefined(AccessTierStatus) || hasPropertyOverride) { - builder.Append(" accessTierStatus:"); + builder.Append(" accessTierStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AccessTierStatus.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AccessTierStatus}'''"); } else { - builder.AppendLine($" '{AccessTierStatus}'"); + builder.AppendLine($"'{AccessTierStatus}'"); } } } @@ -734,56 +734,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShareUsageBytes), out propertyOverride); if (Optional.IsDefined(ShareUsageBytes) || hasPropertyOverride) { - builder.Append(" shareUsageBytes:"); + builder.Append(" shareUsageBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ShareUsageBytes.Value.ToString()}'"); + builder.AppendLine($"'{ShareUsageBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseStatus), out propertyOverride); if (Optional.IsDefined(LeaseStatus) || hasPropertyOverride) { - builder.Append(" leaseStatus:"); + builder.Append(" leaseStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseStatus.Value.ToString()}'"); + builder.AppendLine($"'{LeaseStatus.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseState), out propertyOverride); if (Optional.IsDefined(LeaseState) || hasPropertyOverride) { - builder.Append(" leaseState:"); + builder.Append(" leaseState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseState.Value.ToString()}'"); + builder.AppendLine($"'{LeaseState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseDuration), out propertyOverride); if (Optional.IsDefined(LeaseDuration) || hasPropertyOverride) { - builder.Append(" leaseDuration:"); + builder.Append(" leaseDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LeaseDuration.Value.ToString()}'"); + builder.AppendLine($"'{LeaseDuration.Value.ToString()}'"); } } @@ -792,17 +792,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SignedIdentifiers.Any() || hasPropertyOverride) { - builder.Append(" signedIdentifiers:"); + builder.Append(" signedIdentifiers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SignedIdentifiers) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " signedIdentifiers: "); } builder.AppendLine(" ]"); } @@ -812,15 +812,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnapshotOn), out propertyOverride); if (Optional.IsDefined(SnapshotOn) || hasPropertyOverride) { - builder.Append(" snapshotTime:"); + builder.Append(" snapshotTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SnapshotOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -829,12 +829,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -855,13 +858,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs index 28482082329e3..0c79ec4bddf4c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs @@ -234,21 +234,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -256,42 +256,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -300,58 +300,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPeriodSinceCreationInDays), out propertyOverride); if (Optional.IsDefined(ImmutabilityPeriodSinceCreationInDays) || hasPropertyOverride) { - builder.Append(" immutabilityPeriodSinceCreationInDays:"); + builder.Append(" immutabilityPeriodSinceCreationInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ImmutabilityPeriodSinceCreationInDays.Value}"); + builder.AppendLine($"{ImmutabilityPeriodSinceCreationInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWrites), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWrites) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWrites:"); + builder.Append(" allowProtectedAppendWrites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWrites.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWritesAll), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWritesAll) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWritesAll:"); + builder.Append(" allowProtectedAppendWritesAll: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWritesAll.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -360,12 +360,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -386,13 +389,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/AccountImmutabilityPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/AccountImmutabilityPolicy.Serialization.cs index 69137e5a4d7ce..d474514961f4b 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/AccountImmutabilityPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/AccountImmutabilityPolicy.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPeriodSinceCreationInDays), out propertyOverride); if (Optional.IsDefined(ImmutabilityPeriodSinceCreationInDays) || hasPropertyOverride) { - builder.Append(" immutabilityPeriodSinceCreationInDays:"); + builder.Append(" immutabilityPeriodSinceCreationInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ImmutabilityPeriodSinceCreationInDays.Value}"); + builder.AppendLine($"{ImmutabilityPeriodSinceCreationInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWrites), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWrites) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWrites:"); + builder.Append(" allowProtectedAppendWrites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWrites.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobContainerImmutabilityPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobContainerImmutabilityPolicy.Serialization.cs index ddf527da774c7..36a9ef48a2e6a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobContainerImmutabilityPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobContainerImmutabilityPolicy.Serialization.cs @@ -134,7 +134,7 @@ internal static BlobContainerImmutabilityPolicy DeserializeBlobContainerImmutabi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(UpdateHistoryEntry.DeserializeUpdateHistoryEntry(item, options)); + array.Add(UpdateHistoryEntry.DeserializeUpdateHistoryEntry(item)); } updateHistory = array; continue; @@ -210,14 +210,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (Optional.IsDefined(ETag) || hasPropertyOverride) { - builder.Append(" etag:"); + builder.Append(" etag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ETag.Value.ToString()}'"); + builder.AppendLine($"'{ETag.Value.ToString()}'"); } } @@ -226,17 +226,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UpdateHistory.Any() || hasPropertyOverride) { - builder.Append(" updateHistory:"); + builder.Append(" updateHistory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UpdateHistory) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " updateHistory: "); } builder.AppendLine(" ]"); } @@ -248,58 +248,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPeriodSinceCreationInDays), out propertyOverride); if (Optional.IsDefined(ImmutabilityPeriodSinceCreationInDays) || hasPropertyOverride) { - builder.Append(" immutabilityPeriodSinceCreationInDays:"); + builder.Append(" immutabilityPeriodSinceCreationInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ImmutabilityPeriodSinceCreationInDays.Value}"); + builder.AppendLine($"{ImmutabilityPeriodSinceCreationInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWrites), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWrites) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWrites:"); + builder.Append(" allowProtectedAppendWrites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWrites.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWritesAll), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWritesAll) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWritesAll:"); + builder.Append(" allowProtectedAppendWritesAll: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWritesAll.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -308,12 +308,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -334,13 +337,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyDefinition.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyDefinition.Serialization.cs index 1843b9ea1b496..0c4766aaee2b1 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyDefinition.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyDefinition.Serialization.cs @@ -100,7 +100,7 @@ internal static BlobInventoryPolicyDefinition DeserializeBlobInventoryPolicyDefi { continue; } - filters = BlobInventoryPolicyFilter.DeserializeBlobInventoryPolicyFilter(property.Value, options); + filters = BlobInventoryPolicyFilter.DeserializeBlobInventoryPolicyFilter(property.Value); continue; } if (property.NameEquals("format"u8)) @@ -151,56 +151,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Filters), out propertyOverride); if (Optional.IsDefined(Filters) || hasPropertyOverride) { - builder.Append(" filters:"); + builder.Append(" filters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Filters, options, 2, false); + AppendChildObject(builder, Filters, options, 2, false, " filters: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Format), out propertyOverride); if (Optional.IsDefined(Format) || hasPropertyOverride) { - builder.Append(" format:"); + builder.Append(" format: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Format.ToString()}'"); + builder.AppendLine($"'{Format.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schedule), out propertyOverride); if (Optional.IsDefined(Schedule) || hasPropertyOverride) { - builder.Append(" schedule:"); + builder.Append(" schedule: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Schedule.ToString()}'"); + builder.AppendLine($"'{Schedule.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectType), out propertyOverride); if (Optional.IsDefined(ObjectType) || hasPropertyOverride) { - builder.Append(" objectType:"); + builder.Append(" objectType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ObjectType.ToString()}'"); + builder.AppendLine($"'{ObjectType.ToString()}'"); } } @@ -209,14 +209,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SchemaFields.Any() || hasPropertyOverride) { - builder.Append(" schemaFields:"); + builder.Append(" schemaFields: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SchemaFields) { if (item == null) @@ -243,12 +243,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -269,13 +272,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyFilter.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyFilter.Serialization.cs index ddd6abe13d427..832406491c656 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyFilter.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyFilter.Serialization.cs @@ -216,14 +216,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IncludePrefix.Any() || hasPropertyOverride) { - builder.Append(" prefixMatch:"); + builder.Append(" prefixMatch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IncludePrefix) { if (item == null) @@ -251,14 +251,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExcludePrefix.Any() || hasPropertyOverride) { - builder.Append(" excludePrefix:"); + builder.Append(" excludePrefix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExcludePrefix) { if (item == null) @@ -286,14 +286,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlobTypes.Any() || hasPropertyOverride) { - builder.Append(" blobTypes:"); + builder.Append(" blobTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlobTypes) { if (item == null) @@ -319,45 +319,45 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludeBlobVersions), out propertyOverride); if (Optional.IsDefined(IncludeBlobVersions) || hasPropertyOverride) { - builder.Append(" includeBlobVersions:"); + builder.Append(" includeBlobVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IncludeBlobVersions.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludeSnapshots), out propertyOverride); if (Optional.IsDefined(IncludeSnapshots) || hasPropertyOverride) { - builder.Append(" includeSnapshots:"); + builder.Append(" includeSnapshots: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IncludeSnapshots.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IncludeDeleted), out propertyOverride); if (Optional.IsDefined(IncludeDeleted) || hasPropertyOverride) { - builder.Append(" includeDeleted:"); + builder.Append(" includeDeleted: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IncludeDeleted.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -365,12 +365,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -391,13 +394,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyRule.Serialization.cs index b0f25964e0e97..a2a41d0faa98d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicyRule.Serialization.cs @@ -99,7 +99,7 @@ internal static BlobInventoryPolicyRule DeserializeBlobInventoryPolicyRule(JsonE } if (property.NameEquals("definition"u8)) { - definition = BlobInventoryPolicyDefinition.DeserializeBlobInventoryPolicyDefinition(property.Value, options); + definition = BlobInventoryPolicyDefinition.DeserializeBlobInventoryPolicyDefinition(property.Value); continue; } if (options.Format != "W") @@ -125,21 +125,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -147,36 +147,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Destination), out propertyOverride); if (Optional.IsDefined(Destination) || hasPropertyOverride) { - builder.Append(" destination:"); + builder.Append(" destination: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Destination.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Destination}'''"); } else { - builder.AppendLine($" '{Destination}'"); + builder.AppendLine($"'{Destination}'"); } } } @@ -184,14 +184,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Definition), out propertyOverride); if (Optional.IsDefined(Definition) || hasPropertyOverride) { - builder.Append(" definition:"); + builder.Append(" definition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Definition, options, 2, false); + AppendChildObject(builder, Definition, options, 2, false, " definition: "); } } @@ -199,12 +199,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -225,13 +228,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicySchema.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicySchema.Serialization.cs index d3436a6eaabd0..dc4e386636dba 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicySchema.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobInventoryPolicySchema.Serialization.cs @@ -111,7 +111,7 @@ internal static BlobInventoryPolicySchema DeserializeBlobInventoryPolicySchema(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BlobInventoryPolicyRule.DeserializeBlobInventoryPolicyRule(item, options)); + array.Add(BlobInventoryPolicyRule.DeserializeBlobInventoryPolicyRule(item)); } rules = array; continue; @@ -139,36 +139,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Destination), out propertyOverride); if (Optional.IsDefined(Destination) || hasPropertyOverride) { - builder.Append(" destination:"); + builder.Append(" destination: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Destination.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Destination}'''"); } else { - builder.AppendLine($" '{Destination}'"); + builder.AppendLine($"'{Destination}'"); } } } @@ -178,17 +178,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Rules.Any() || hasPropertyOverride) { - builder.Append(" rules:"); + builder.Append(" rules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Rules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " rules: "); } builder.AppendLine(" ]"); } @@ -199,12 +199,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -225,13 +228,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreContent.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreContent.Serialization.cs index 0331c53930636..13692a2778238 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreContent.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreContent.Serialization.cs @@ -92,7 +92,7 @@ internal static BlobRestoreContent DeserializeBlobRestoreContent(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BlobRestoreRange.DeserializeBlobRestoreRange(item, options)); + array.Add(BlobRestoreRange.DeserializeBlobRestoreRange(item)); } blobRanges = array; continue; @@ -120,15 +120,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeToRestore), out propertyOverride); if (Optional.IsDefined(TimeToRestore) || hasPropertyOverride) { - builder.Append(" timetoRestore:"); + builder.Append(" timetoRestore: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeToRestore, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -137,17 +137,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlobRanges.Any() || hasPropertyOverride) { - builder.Append(" blobRanges:"); + builder.Append(" blobRanges: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlobRanges) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " blobRanges: "); } builder.AppendLine(" ]"); } @@ -158,12 +158,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -184,13 +187,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreRange.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreRange.Serialization.cs index c0fabfb9bcaf0..fb21fe831cf97 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreRange.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreRange.Serialization.cs @@ -109,21 +109,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartRange), out propertyOverride); if (Optional.IsDefined(StartRange) || hasPropertyOverride) { - builder.Append(" startRange:"); + builder.Append(" startRange: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartRange.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartRange}'''"); } else { - builder.AppendLine($" '{StartRange}'"); + builder.AppendLine($"'{StartRange}'"); } } } @@ -131,21 +131,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndRange), out propertyOverride); if (Optional.IsDefined(EndRange) || hasPropertyOverride) { - builder.Append(" endRange:"); + builder.Append(" endRange: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndRange.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndRange}'''"); } else { - builder.AppendLine($" '{EndRange}'"); + builder.AppendLine($"'{EndRange}'"); } } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreStatus.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreStatus.Serialization.cs index 71e5f3f7bb809..e900221fcfef0 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreStatus.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobRestoreStatus.Serialization.cs @@ -119,7 +119,7 @@ internal static BlobRestoreStatus DeserializeBlobRestoreStatus(JsonElement eleme { continue; } - parameters = BlobRestoreContent.DeserializeBlobRestoreContent(property.Value, options); + parameters = BlobRestoreContent.DeserializeBlobRestoreContent(property.Value); continue; } if (options.Format != "W") @@ -145,35 +145,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailureReason), out propertyOverride); if (Optional.IsDefined(FailureReason) || hasPropertyOverride) { - builder.Append(" failureReason:"); + builder.Append(" failureReason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FailureReason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FailureReason}'''"); } else { - builder.AppendLine($" '{FailureReason}'"); + builder.AppendLine($"'{FailureReason}'"); } } } @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoreId), out propertyOverride); if (Optional.IsDefined(RestoreId) || hasPropertyOverride) { - builder.Append(" restoreId:"); + builder.Append(" restoreId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RestoreId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RestoreId}'''"); } else { - builder.AppendLine($" '{RestoreId}'"); + builder.AppendLine($"'{RestoreId}'"); } } } @@ -203,14 +203,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Parameters, options, 2, false); + AppendChildObject(builder, Parameters, options, 2, false, " parameters: "); } } @@ -218,12 +218,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -244,13 +247,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceChangeFeed.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceChangeFeed.Serialization.cs index 9aec5c42c27c7..a7f3ae4b04a62 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceChangeFeed.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceChangeFeed.Serialization.cs @@ -123,29 +123,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) { - builder.Append(" retentionInDays:"); + builder.Append(" retentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionInDays.Value}"); + builder.AppendLine($"{RetentionInDays.Value}"); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceItems.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceItems.Serialization.cs index 17151381c3a64..5a1bd4ba8397b 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceItems.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/BlobServiceItems.Serialization.cs @@ -92,7 +92,7 @@ internal static BlobServiceItems DeserializeBlobServiceItems(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BlobServiceData.DeserializeBlobServiceData(item, options)); + array.Add(BlobServiceData.DeserializeBlobServiceData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterCreation.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterCreation.Serialization.cs index 4817890031cbb..58ce96f2c127d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterCreation.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterCreation.Serialization.cs @@ -116,28 +116,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterCreationGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterCreationGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterCreationGreaterThan:"); + builder.Append(" daysAfterCreationGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterCreationGreaterThan.ToString()}'"); + builder.AppendLine($"'{DaysAfterCreationGreaterThan.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterLastTierChangeGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterLastTierChangeGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterLastTierChangeGreaterThan:"); + builder.Append(" daysAfterLastTierChangeGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterLastTierChangeGreaterThan.Value.ToString()}'"); + builder.AppendLine($"'{DaysAfterLastTierChangeGreaterThan.Value.ToString()}'"); } } @@ -145,12 +145,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -171,13 +174,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterModification.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterModification.Serialization.cs index 757ac04feb003..59f9aa4a84107 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterModification.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DateAfterModification.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterModificationGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterModificationGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterModificationGreaterThan:"); + builder.Append(" daysAfterModificationGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterModificationGreaterThan.Value.ToString()}'"); + builder.AppendLine($"'{DaysAfterModificationGreaterThan.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterLastAccessTimeGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterLastAccessTimeGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterLastAccessTimeGreaterThan:"); + builder.Append(" daysAfterLastAccessTimeGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterLastAccessTimeGreaterThan.Value.ToString()}'"); + builder.AppendLine($"'{DaysAfterLastAccessTimeGreaterThan.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterLastTierChangeGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterLastTierChangeGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterLastTierChangeGreaterThan:"); + builder.Append(" daysAfterLastTierChangeGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterLastTierChangeGreaterThan.Value.ToString()}'"); + builder.AppendLine($"'{DaysAfterLastTierChangeGreaterThan.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaysAfterCreationGreaterThan), out propertyOverride); if (Optional.IsDefined(DaysAfterCreationGreaterThan) || hasPropertyOverride) { - builder.Append(" daysAfterCreationGreaterThan:"); + builder.Append(" daysAfterCreationGreaterThan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DaysAfterCreationGreaterThan.Value.ToString()}'"); + builder.AppendLine($"'{DaysAfterCreationGreaterThan.Value.ToString()}'"); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeleteRetentionPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeleteRetentionPolicy.Serialization.cs index 7422aaa436f0f..54c5d89c1de5b 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeleteRetentionPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeleteRetentionPolicy.Serialization.cs @@ -138,44 +138,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Days), out propertyOverride); if (Optional.IsDefined(Days) || hasPropertyOverride) { - builder.Append(" days:"); + builder.Append(" days: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Days.Value}"); + builder.AppendLine($"{Days.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowPermanentDelete), out propertyOverride); if (Optional.IsDefined(AllowPermanentDelete) || hasPropertyOverride) { - builder.Append(" allowPermanentDelete:"); + builder.Append(" allowPermanentDelete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowPermanentDelete.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -183,12 +183,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -209,13 +212,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeletedAccountListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeletedAccountListResult.Serialization.cs index 56d2c0ca4cf4e..0b0ae24409685 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeletedAccountListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/DeletedAccountListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static DeletedAccountListResult DeserializeDeletedAccountListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeletedAccountData.DeserializeDeletedAccountData(item, options)); + array.Add(DeletedAccountData.DeserializeDeletedAccountData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeKeyVaultProperties.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeKeyVaultProperties.Serialization.cs index e14a4c1974d68..a92b29f956082 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeKeyVaultProperties.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeKeyVaultProperties.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); if (Optional.IsDefined(KeyUri) || hasPropertyOverride) { - builder.Append(" keyUri:"); + builder.Append(" keyUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyUri.AbsoluteUri}'"); + builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentVersionedKeyIdentifier), out propertyOverride); if (Optional.IsDefined(CurrentVersionedKeyIdentifier) || hasPropertyOverride) { - builder.Append(" currentVersionedKeyIdentifier:"); + builder.Append(" currentVersionedKeyIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentVersionedKeyIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentVersionedKeyIdentifier}'''"); } else { - builder.AppendLine($" '{CurrentVersionedKeyIdentifier}'"); + builder.AppendLine($"'{CurrentVersionedKeyIdentifier}'"); } } } @@ -170,15 +170,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastKeyRotationTimestamp), out propertyOverride); if (Optional.IsDefined(LastKeyRotationTimestamp) || hasPropertyOverride) { - builder.Append(" lastKeyRotationTimestamp:"); + builder.Append(" lastKeyRotationTimestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastKeyRotationTimestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeListResult.Serialization.cs index 68363d335fc71..0f697a48b8f98 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/EncryptionScopeListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static EncryptionScopeListResult DeserializeEncryptionScopeListResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(EncryptionScopeData.DeserializeEncryptionScopeData(item, options)); + array.Add(EncryptionScopeData.DeserializeEncryptionScopeData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileServiceItems.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileServiceItems.Serialization.cs index d4a30126f619c..af40f9c57d6d1 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileServiceItems.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileServiceItems.Serialization.cs @@ -92,7 +92,7 @@ internal static FileServiceItems DeserializeFileServiceItems(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FileServiceData.DeserializeFileServiceData(item, options)); + array.Add(FileServiceData.DeserializeFileServiceData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileShareItems.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileShareItems.Serialization.cs index 4e0b7a890eae4..c5704f5785aea 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileShareItems.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FileShareItems.Serialization.cs @@ -98,7 +98,7 @@ internal static FileShareItems DeserializeFileShareItems(JsonElement element, Mo List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FileShareData.DeserializeFileShareData(item, options)); + array.Add(FileShareData.DeserializeFileShareData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FilesIdentityBasedAuthentication.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FilesIdentityBasedAuthentication.Serialization.cs index 21e2bd6089502..afaafa6b1dec7 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FilesIdentityBasedAuthentication.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/FilesIdentityBasedAuthentication.Serialization.cs @@ -96,7 +96,7 @@ internal static FilesIdentityBasedAuthentication DeserializeFilesIdentityBasedAu { continue; } - activeDirectoryProperties = StorageActiveDirectoryProperties.DeserializeStorageActiveDirectoryProperties(property.Value, options); + activeDirectoryProperties = StorageActiveDirectoryProperties.DeserializeStorageActiveDirectoryProperties(property.Value); continue; } if (property.NameEquals("defaultSharePermission"u8)) @@ -131,42 +131,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DirectoryServiceOptions), out propertyOverride); if (Optional.IsDefined(DirectoryServiceOptions) || hasPropertyOverride) { - builder.Append(" directoryServiceOptions:"); + builder.Append(" directoryServiceOptions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DirectoryServiceOptions.ToString()}'"); + builder.AppendLine($"'{DirectoryServiceOptions.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActiveDirectoryProperties), out propertyOverride); if (Optional.IsDefined(ActiveDirectoryProperties) || hasPropertyOverride) { - builder.Append(" activeDirectoryProperties:"); + builder.Append(" activeDirectoryProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ActiveDirectoryProperties, options, 2, false); + AppendChildObject(builder, ActiveDirectoryProperties, options, 2, false, " activeDirectoryProperties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultSharePermission), out propertyOverride); if (Optional.IsDefined(DefaultSharePermission) || hasPropertyOverride) { - builder.Append(" defaultSharePermission:"); + builder.Append(" defaultSharePermission: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultSharePermission.Value.ToString()}'"); + builder.AppendLine($"'{DefaultSharePermission.Value.ToString()}'"); } } @@ -174,12 +174,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -200,13 +203,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GeoReplicationStatistics.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GeoReplicationStatistics.Serialization.cs index 1f339f6e9bf6a..90125374736b2 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GeoReplicationStatistics.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GeoReplicationStatistics.Serialization.cs @@ -138,44 +138,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastSyncOn), out propertyOverride); if (Optional.IsDefined(LastSyncOn) || hasPropertyOverride) { - builder.Append(" lastSyncTime:"); + builder.Append(" lastSyncTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastSyncOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanFailover), out propertyOverride); if (Optional.IsDefined(CanFailover) || hasPropertyOverride) { - builder.Append(" canFailover:"); + builder.Append(" canFailover: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CanFailover.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -183,12 +183,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -209,13 +212,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetAccountSasResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetAccountSasResult.Serialization.cs index 84f974df4e003..02bc87104ba82 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetAccountSasResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetAccountSasResult.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccountSasToken), out propertyOverride); if (Optional.IsDefined(AccountSasToken) || hasPropertyOverride) { - builder.Append(" accountSasToken:"); + builder.Append(" accountSasToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AccountSasToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AccountSasToken}'''"); } else { - builder.AppendLine($" '{AccountSasToken}'"); + builder.AppendLine($"'{AccountSasToken}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetServiceSasResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetServiceSasResult.Serialization.cs index a3a4269e36340..1e80601d2bd95 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetServiceSasResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/GetServiceSasResult.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceSasToken), out propertyOverride); if (Optional.IsDefined(ServiceSasToken) || hasPropertyOverride) { - builder.Append(" serviceSasToken:"); + builder.Append(" serviceSasToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceSasToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceSasToken}'''"); } else { - builder.AppendLine($" '{ServiceSasToken}'"); + builder.AppendLine($"'{ServiceSasToken}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageAccount.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageAccount.Serialization.cs index b7f16388d4acb..7c9807048a838 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageAccount.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageAccount.Serialization.cs @@ -97,7 +97,7 @@ internal static ImmutableStorageAccount DeserializeImmutableStorageAccount(JsonE { continue; } - immutabilityPolicy = AccountImmutabilityPolicy.DeserializeAccountImmutabilityPolicy(property.Value, options); + immutabilityPolicy = AccountImmutabilityPolicy.DeserializeAccountImmutabilityPolicy(property.Value); continue; } if (options.Format != "W") @@ -123,29 +123,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPolicy), out propertyOverride); if (Optional.IsDefined(ImmutabilityPolicy) || hasPropertyOverride) { - builder.Append(" immutabilityPolicy:"); + builder.Append(" immutabilityPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ImmutabilityPolicy, options, 2, false); + AppendChildObject(builder, ImmutabilityPolicy, options, 2, false, " immutabilityPolicy: "); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageWithVersioning.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageWithVersioning.Serialization.cs index 44b1bb6de6a5b..642be2e238939 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageWithVersioning.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ImmutableStorageWithVersioning.Serialization.cs @@ -138,44 +138,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeStamp), out propertyOverride); if (Optional.IsDefined(TimeStamp) || hasPropertyOverride) { - builder.Append(" timeStamp:"); + builder.Append(" timeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MigrationState), out propertyOverride); if (Optional.IsDefined(MigrationState) || hasPropertyOverride) { - builder.Append(" migrationState:"); + builder.Append(" migrationState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MigrationState.Value.ToString()}'"); + builder.AppendLine($"'{MigrationState.Value.ToString()}'"); } } @@ -183,12 +183,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -209,13 +212,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LastAccessTimeTrackingPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LastAccessTimeTrackingPolicy.Serialization.cs index 07435ed6102de..f831bcc7db6bb 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LastAccessTimeTrackingPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LastAccessTimeTrackingPolicy.Serialization.cs @@ -157,43 +157,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.Value.ToString()}'"); + builder.AppendLine($"'{Name.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enable:"); + builder.Append(" enable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TrackingGranularityInDays), out propertyOverride); if (Optional.IsDefined(TrackingGranularityInDays) || hasPropertyOverride) { - builder.Append(" trackingGranularityInDays:"); + builder.Append(" trackingGranularityInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TrackingGranularityInDays.Value}"); + builder.AppendLine($"{TrackingGranularityInDays.Value}"); } } @@ -202,14 +202,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlobType.Any() || hasPropertyOverride) { - builder.Append(" blobType:"); + builder.Append(" blobType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlobType) { if (item == null) @@ -236,12 +236,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -262,13 +265,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseContainerResponse.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseContainerResponse.Serialization.cs index 6f6127dbb889d..710fd8fc490be 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseContainerResponse.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseContainerResponse.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseId), out propertyOverride); if (Optional.IsDefined(LeaseId) || hasPropertyOverride) { - builder.Append(" leaseId:"); + builder.Append(" leaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LeaseId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LeaseId}'''"); } else { - builder.AppendLine($" '{LeaseId}'"); + builder.AppendLine($"'{LeaseId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseTimeSeconds), out propertyOverride); if (Optional.IsDefined(LeaseTimeSeconds) || hasPropertyOverride) { - builder.Append(" leaseTimeSeconds:"); + builder.Append(" leaseTimeSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LeaseTimeSeconds.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LeaseTimeSeconds}'''"); } else { - builder.AppendLine($" '{LeaseTimeSeconds}'"); + builder.AppendLine($"'{LeaseTimeSeconds}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseShareResponse.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseShareResponse.Serialization.cs index cdd26b9d9cdd4..d99b2004dc133 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseShareResponse.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LeaseShareResponse.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseId), out propertyOverride); if (Optional.IsDefined(LeaseId) || hasPropertyOverride) { - builder.Append(" leaseId:"); + builder.Append(" leaseId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LeaseId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LeaseId}'''"); } else { - builder.AppendLine($" '{LeaseId}'"); + builder.AppendLine($"'{LeaseId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LeaseTimeSeconds), out propertyOverride); if (Optional.IsDefined(LeaseTimeSeconds) || hasPropertyOverride) { - builder.Append(" leaseTimeSeconds:"); + builder.Append(" leaseTimeSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LeaseTimeSeconds.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LeaseTimeSeconds}'''"); } else { - builder.AppendLine($" '{LeaseTimeSeconds}'"); + builder.AppendLine($"'{LeaseTimeSeconds}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHold.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHold.Serialization.cs index cea41fe05a020..480fa611d9b17 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHold.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHold.Serialization.cs @@ -144,14 +144,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Tags) { if (item == null) @@ -177,30 +177,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLegalHold), out propertyOverride); if (Optional.IsDefined(HasLegalHold) || hasPropertyOverride) { - builder.Append(" hasLegalHold:"); + builder.Append(" hasLegalHold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLegalHold.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWritesAll), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWritesAll) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWritesAll:"); + builder.Append(" allowProtectedAppendWritesAll: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWritesAll.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -208,12 +208,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -234,13 +237,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldProperties.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldProperties.Serialization.cs index c05c6fb48a891..6ea5f7f39d096 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldProperties.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldProperties.Serialization.cs @@ -112,7 +112,7 @@ internal static LegalHoldProperties DeserializeLegalHoldProperties(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LegalHoldTag.DeserializeLegalHoldTag(item, options)); + array.Add(LegalHoldTag.DeserializeLegalHoldTag(item)); } tags = array; continue; @@ -123,7 +123,7 @@ internal static LegalHoldProperties DeserializeLegalHoldProperties(JsonElement e { continue; } - protectedAppendWritesHistory = ProtectedAppendWritesHistory.DeserializeProtectedAppendWritesHistory(property.Value, options); + protectedAppendWritesHistory = ProtectedAppendWritesHistory.DeserializeProtectedAppendWritesHistory(property.Value); continue; } if (options.Format != "W") @@ -151,17 +151,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Tags) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " tags: "); } builder.AppendLine(" ]"); } @@ -171,29 +171,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLegalHold), out propertyOverride); if (Optional.IsDefined(HasLegalHold) || hasPropertyOverride) { - builder.Append(" hasLegalHold:"); + builder.Append(" hasLegalHold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLegalHold.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProtectedAppendWritesHistory), out propertyOverride); if (Optional.IsDefined(ProtectedAppendWritesHistory) || hasPropertyOverride) { - builder.Append(" protectedAppendWritesHistory:"); + builder.Append(" protectedAppendWritesHistory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ProtectedAppendWritesHistory, options, 2, false); + AppendChildObject(builder, ProtectedAppendWritesHistory, options, 2, false, " protectedAppendWritesHistory: "); } } @@ -201,12 +201,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -227,13 +230,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldTag.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldTag.Serialization.cs index dacc3752cffc4..4394d97d1580c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldTag.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LegalHoldTag.Serialization.cs @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tag), out propertyOverride); if (Optional.IsDefined(Tag) || hasPropertyOverride) { - builder.Append(" tag:"); + builder.Append(" tag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tag.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tag}'''"); } else { - builder.AppendLine($" '{Tag}'"); + builder.AppendLine($"'{Tag}'"); } } } @@ -178,36 +178,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectIdentifier), out propertyOverride); if (Optional.IsDefined(ObjectIdentifier) || hasPropertyOverride) { - builder.Append(" objectIdentifier:"); + builder.Append(" objectIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ObjectIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ObjectIdentifier}'''"); } else { - builder.AppendLine($" '{ObjectIdentifier}'"); + builder.AppendLine($"'{ObjectIdentifier}'"); } } } @@ -215,35 +215,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Upn), out propertyOverride); if (Optional.IsDefined(Upn) || hasPropertyOverride) { - builder.Append(" upn:"); + builder.Append(" upn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Upn.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Upn}'''"); } else { - builder.AppendLine($" '{Upn}'"); + builder.AppendLine($"'{Upn}'"); } } } @@ -252,12 +252,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -278,13 +281,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListBlobInventoryPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListBlobInventoryPolicy.Serialization.cs index b6e7ad942cba0..5e0dcb0bc65a1 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListBlobInventoryPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListBlobInventoryPolicy.Serialization.cs @@ -92,7 +92,7 @@ internal static ListBlobInventoryPolicy DeserializeListBlobInventoryPolicy(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BlobInventoryPolicyData.DeserializeBlobInventoryPolicyData(item, options)); + array.Add(BlobInventoryPolicyData.DeserializeBlobInventoryPolicyData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListContainerItems.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListContainerItems.Serialization.cs index bee419565f2de..b6310a8710420 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListContainerItems.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListContainerItems.Serialization.cs @@ -98,7 +98,7 @@ internal static ListContainerItems DeserializeListContainerItems(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(BlobContainerData.DeserializeBlobContainerData(item, options)); + array.Add(BlobContainerData.DeserializeBlobContainerData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueResource.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueResource.Serialization.cs index 7e94489f3bb37..5789e116df18a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueResource.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueResource.Serialization.cs @@ -98,7 +98,7 @@ internal static ListQueueResource DeserializeListQueueResource(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageQueueData.DeserializeStorageQueueData(item, options)); + array.Add(StorageQueueData.DeserializeStorageQueueData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueServices.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueServices.Serialization.cs index 5197048388c9d..173839a2a1904 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueServices.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListQueueServices.Serialization.cs @@ -92,7 +92,7 @@ internal static ListQueueServices DeserializeListQueueServices(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueueServiceData.DeserializeQueueServiceData(item, options)); + array.Add(QueueServiceData.DeserializeQueueServiceData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableResource.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableResource.Serialization.cs index 1b5777b52d6dc..c4060fd64304d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableResource.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableResource.Serialization.cs @@ -98,7 +98,7 @@ internal static ListTableResource DeserializeListTableResource(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TableData.DeserializeTableData(item, options)); + array.Add(TableData.DeserializeTableData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableServices.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableServices.Serialization.cs index 10f443ce477de..2930ccec95add 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableServices.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ListTableServices.Serialization.cs @@ -92,7 +92,7 @@ internal static ListTableServices DeserializeListTableServices(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TableServiceData.DeserializeTableServiceData(item, options)); + array.Add(TableServiceData.DeserializeTableServiceData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserKeys.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserKeys.Serialization.cs index 401730e3b5f23..b93c4e9ad3524 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserKeys.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserKeys.Serialization.cs @@ -97,7 +97,7 @@ internal static LocalUserKeys DeserializeLocalUserKeys(JsonElement element, Mode List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageSshPublicKey.DeserializeStorageSshPublicKey(item, options)); + array.Add(StorageSshPublicKey.DeserializeStorageSshPublicKey(item)); } sshAuthorizedKeys = array; continue; @@ -132,17 +132,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SshAuthorizedKeys.Any() || hasPropertyOverride) { - builder.Append(" sshAuthorizedKeys:"); + builder.Append(" sshAuthorizedKeys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SshAuthorizedKeys) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " sshAuthorizedKeys: "); } builder.AppendLine(" ]"); } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SharedKey), out propertyOverride); if (Optional.IsDefined(SharedKey) || hasPropertyOverride) { - builder.Append(" sharedKey:"); + builder.Append(" sharedKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SharedKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SharedKey}'''"); } else { - builder.AppendLine($" '{SharedKey}'"); + builder.AppendLine($"'{SharedKey}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserRegeneratePasswordResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserRegeneratePasswordResult.Serialization.cs index 6a5403196bae2..6ac1a6cb40dd2 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserRegeneratePasswordResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUserRegeneratePasswordResult.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SshPassword), out propertyOverride); if (Optional.IsDefined(SshPassword) || hasPropertyOverride) { - builder.Append(" sshPassword:"); + builder.Append(" sshPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SshPassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SshPassword}'''"); } else { - builder.AppendLine($" '{SshPassword}'"); + builder.AppendLine($"'{SshPassword}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUsers.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUsers.Serialization.cs index 84e712ae2a164..71b4a61b914b1 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUsers.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/LocalUsers.Serialization.cs @@ -92,7 +92,7 @@ internal static LocalUsers DeserializeLocalUsers(JsonElement element, ModelReade List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountLocalUserData.DeserializeStorageAccountLocalUserData(item, options)); + array.Add(StorageAccountLocalUserData.DeserializeStorageAccountLocalUserData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyAction.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyAction.Serialization.cs index b33e74797f1c1..d92eed9628911 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyAction.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyAction.Serialization.cs @@ -94,7 +94,7 @@ internal static ManagementPolicyAction DeserializeManagementPolicyAction(JsonEle { continue; } - baseBlob = ManagementPolicyBaseBlob.DeserializeManagementPolicyBaseBlob(property.Value, options); + baseBlob = ManagementPolicyBaseBlob.DeserializeManagementPolicyBaseBlob(property.Value); continue; } if (property.NameEquals("snapshot"u8)) @@ -103,7 +103,7 @@ internal static ManagementPolicyAction DeserializeManagementPolicyAction(JsonEle { continue; } - snapshot = ManagementPolicySnapShot.DeserializeManagementPolicySnapShot(property.Value, options); + snapshot = ManagementPolicySnapShot.DeserializeManagementPolicySnapShot(property.Value); continue; } if (property.NameEquals("version"u8)) @@ -112,7 +112,7 @@ internal static ManagementPolicyAction DeserializeManagementPolicyAction(JsonEle { continue; } - version = ManagementPolicyVersion.DeserializeManagementPolicyVersion(property.Value, options); + version = ManagementPolicyVersion.DeserializeManagementPolicyVersion(property.Value); continue; } if (options.Format != "W") @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseBlob), out propertyOverride); if (Optional.IsDefined(BaseBlob) || hasPropertyOverride) { - builder.Append(" baseBlob:"); + builder.Append(" baseBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BaseBlob, options, 2, false); + AppendChildObject(builder, BaseBlob, options, 2, false, " baseBlob: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Snapshot), out propertyOverride); if (Optional.IsDefined(Snapshot) || hasPropertyOverride) { - builder.Append(" snapshot:"); + builder.Append(" snapshot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Snapshot, options, 2, false); + AppendChildObject(builder, Snapshot, options, 2, false, " snapshot: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Version, options, 2, false); + AppendChildObject(builder, Version, options, 2, false, " version: "); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyBaseBlob.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyBaseBlob.Serialization.cs index 9905c026bb856..d396f14962b1d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyBaseBlob.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyBaseBlob.Serialization.cs @@ -112,7 +112,7 @@ internal static ManagementPolicyBaseBlob DeserializeManagementPolicyBaseBlob(Jso { continue; } - tierToCool = DateAfterModification.DeserializeDateAfterModification(property.Value, options); + tierToCool = DateAfterModification.DeserializeDateAfterModification(property.Value); continue; } if (property.NameEquals("tierToArchive"u8)) @@ -121,7 +121,7 @@ internal static ManagementPolicyBaseBlob DeserializeManagementPolicyBaseBlob(Jso { continue; } - tierToArchive = DateAfterModification.DeserializeDateAfterModification(property.Value, options); + tierToArchive = DateAfterModification.DeserializeDateAfterModification(property.Value); continue; } if (property.NameEquals("tierToCold"u8)) @@ -130,7 +130,7 @@ internal static ManagementPolicyBaseBlob DeserializeManagementPolicyBaseBlob(Jso { continue; } - tierToCold = DateAfterModification.DeserializeDateAfterModification(property.Value, options); + tierToCold = DateAfterModification.DeserializeDateAfterModification(property.Value); continue; } if (property.NameEquals("tierToHot"u8)) @@ -139,7 +139,7 @@ internal static ManagementPolicyBaseBlob DeserializeManagementPolicyBaseBlob(Jso { continue; } - tierToHot = DateAfterModification.DeserializeDateAfterModification(property.Value, options); + tierToHot = DateAfterModification.DeserializeDateAfterModification(property.Value); continue; } if (property.NameEquals("delete"u8)) @@ -148,7 +148,7 @@ internal static ManagementPolicyBaseBlob DeserializeManagementPolicyBaseBlob(Jso { continue; } - delete = DateAfterModification.DeserializeDateAfterModification(property.Value, options); + delete = DateAfterModification.DeserializeDateAfterModification(property.Value); continue; } if (property.NameEquals("enableAutoTierToHotFromCool"u8)) @@ -183,85 +183,85 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCool), out propertyOverride); if (Optional.IsDefined(TierToCool) || hasPropertyOverride) { - builder.Append(" tierToCool:"); + builder.Append(" tierToCool: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCool, options, 2, false); + AppendChildObject(builder, TierToCool, options, 2, false, " tierToCool: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToArchive), out propertyOverride); if (Optional.IsDefined(TierToArchive) || hasPropertyOverride) { - builder.Append(" tierToArchive:"); + builder.Append(" tierToArchive: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToArchive, options, 2, false); + AppendChildObject(builder, TierToArchive, options, 2, false, " tierToArchive: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCold), out propertyOverride); if (Optional.IsDefined(TierToCold) || hasPropertyOverride) { - builder.Append(" tierToCold:"); + builder.Append(" tierToCold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCold, options, 2, false); + AppendChildObject(builder, TierToCold, options, 2, false, " tierToCold: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToHot), out propertyOverride); if (Optional.IsDefined(TierToHot) || hasPropertyOverride) { - builder.Append(" tierToHot:"); + builder.Append(" tierToHot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToHot, options, 2, false); + AppendChildObject(builder, TierToHot, options, 2, false, " tierToHot: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Delete), out propertyOverride); if (Optional.IsDefined(Delete) || hasPropertyOverride) { - builder.Append(" delete:"); + builder.Append(" delete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Delete, options, 2, false); + AppendChildObject(builder, Delete, options, 2, false, " delete: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableAutoTierToHotFromCool), out propertyOverride); if (Optional.IsDefined(EnableAutoTierToHotFromCool) || hasPropertyOverride) { - builder.Append(" enableAutoTierToHotFromCool:"); + builder.Append(" enableAutoTierToHotFromCool: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableAutoTierToHotFromCool.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -269,12 +269,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -295,13 +298,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyDefinition.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyDefinition.Serialization.cs index f6458bfed6010..4e1ea559941c3 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyDefinition.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyDefinition.Serialization.cs @@ -81,7 +81,7 @@ internal static ManagementPolicyDefinition DeserializeManagementPolicyDefinition { if (property.NameEquals("actions"u8)) { - actions = ManagementPolicyAction.DeserializeManagementPolicyAction(property.Value, options); + actions = ManagementPolicyAction.DeserializeManagementPolicyAction(property.Value); continue; } if (property.NameEquals("filters"u8)) @@ -90,7 +90,7 @@ internal static ManagementPolicyDefinition DeserializeManagementPolicyDefinition { continue; } - filters = ManagementPolicyFilter.DeserializeManagementPolicyFilter(property.Value, options); + filters = ManagementPolicyFilter.DeserializeManagementPolicyFilter(property.Value); continue; } if (options.Format != "W") @@ -116,28 +116,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Actions), out propertyOverride); if (Optional.IsDefined(Actions) || hasPropertyOverride) { - builder.Append(" actions:"); + builder.Append(" actions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Actions, options, 2, false); + AppendChildObject(builder, Actions, options, 2, false, " actions: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Filters), out propertyOverride); if (Optional.IsDefined(Filters) || hasPropertyOverride) { - builder.Append(" filters:"); + builder.Append(" filters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Filters, options, 2, false); + AppendChildObject(builder, Filters, options, 2, false, " filters: "); } } @@ -145,12 +145,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -171,13 +174,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyFilter.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyFilter.Serialization.cs index 2a2748683eac1..914fdac698772 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyFilter.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyFilter.Serialization.cs @@ -134,7 +134,7 @@ internal static ManagementPolicyFilter DeserializeManagementPolicyFilter(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementPolicyTagFilter.DeserializeManagementPolicyTagFilter(item, options)); + array.Add(ManagementPolicyTagFilter.DeserializeManagementPolicyTagFilter(item)); } blobIndexMatch = array; continue; @@ -164,14 +164,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrefixMatch.Any() || hasPropertyOverride) { - builder.Append(" prefixMatch:"); + builder.Append(" prefixMatch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrefixMatch) { if (item == null) @@ -199,14 +199,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlobTypes.Any() || hasPropertyOverride) { - builder.Append(" blobTypes:"); + builder.Append(" blobTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlobTypes) { if (item == null) @@ -234,17 +234,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlobIndexMatch.Any() || hasPropertyOverride) { - builder.Append(" blobIndexMatch:"); + builder.Append(" blobIndexMatch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlobIndexMatch) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " blobIndexMatch: "); } builder.AppendLine(" ]"); } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyRule.Serialization.cs index 6b7260b1f0225..66a26b2c5c0e9 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyRule.Serialization.cs @@ -106,7 +106,7 @@ internal static ManagementPolicyRule DeserializeManagementPolicyRule(JsonElement } if (property.NameEquals("definition"u8)) { - definition = ManagementPolicyDefinition.DeserializeManagementPolicyDefinition(property.Value, options); + definition = ManagementPolicyDefinition.DeserializeManagementPolicyDefinition(property.Value); continue; } if (options.Format != "W") @@ -132,21 +132,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -154,29 +154,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Definition), out propertyOverride); if (Optional.IsDefined(Definition) || hasPropertyOverride) { - builder.Append(" definition:"); + builder.Append(" definition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Definition, options, 2, false); + AppendChildObject(builder, Definition, options, 2, false, " definition: "); } } @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySchema.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySchema.Serialization.cs index 53924a38595bf..eb7154e1e3fbf 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySchema.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySchema.Serialization.cs @@ -84,7 +84,7 @@ internal static ManagementPolicySchema DeserializeManagementPolicySchema(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ManagementPolicyRule.DeserializeManagementPolicyRule(item, options)); + array.Add(ManagementPolicyRule.DeserializeManagementPolicyRule(item)); } rules = array; continue; @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Rules.Any() || hasPropertyOverride) { - builder.Append(" rules:"); + builder.Append(" rules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Rules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " rules: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySnapShot.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySnapShot.Serialization.cs index 5a1fe59c92e98..1adae97794522 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySnapShot.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicySnapShot.Serialization.cs @@ -106,7 +106,7 @@ internal static ManagementPolicySnapShot DeserializeManagementPolicySnapShot(Jso { continue; } - tierToCool = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToCool = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToArchive"u8)) @@ -115,7 +115,7 @@ internal static ManagementPolicySnapShot DeserializeManagementPolicySnapShot(Jso { continue; } - tierToArchive = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToArchive = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToCold"u8)) @@ -124,7 +124,7 @@ internal static ManagementPolicySnapShot DeserializeManagementPolicySnapShot(Jso { continue; } - tierToCold = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToCold = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToHot"u8)) @@ -133,7 +133,7 @@ internal static ManagementPolicySnapShot DeserializeManagementPolicySnapShot(Jso { continue; } - tierToHot = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToHot = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("delete"u8)) @@ -142,7 +142,7 @@ internal static ManagementPolicySnapShot DeserializeManagementPolicySnapShot(Jso { continue; } - delete = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + delete = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (options.Format != "W") @@ -168,70 +168,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCool), out propertyOverride); if (Optional.IsDefined(TierToCool) || hasPropertyOverride) { - builder.Append(" tierToCool:"); + builder.Append(" tierToCool: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCool, options, 2, false); + AppendChildObject(builder, TierToCool, options, 2, false, " tierToCool: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToArchive), out propertyOverride); if (Optional.IsDefined(TierToArchive) || hasPropertyOverride) { - builder.Append(" tierToArchive:"); + builder.Append(" tierToArchive: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToArchive, options, 2, false); + AppendChildObject(builder, TierToArchive, options, 2, false, " tierToArchive: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCold), out propertyOverride); if (Optional.IsDefined(TierToCold) || hasPropertyOverride) { - builder.Append(" tierToCold:"); + builder.Append(" tierToCold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCold, options, 2, false); + AppendChildObject(builder, TierToCold, options, 2, false, " tierToCold: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToHot), out propertyOverride); if (Optional.IsDefined(TierToHot) || hasPropertyOverride) { - builder.Append(" tierToHot:"); + builder.Append(" tierToHot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToHot, options, 2, false); + AppendChildObject(builder, TierToHot, options, 2, false, " tierToHot: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Delete), out propertyOverride); if (Optional.IsDefined(Delete) || hasPropertyOverride) { - builder.Append(" delete:"); + builder.Append(" delete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Delete, options, 2, false); + AppendChildObject(builder, Delete, options, 2, false, " delete: "); } } @@ -239,12 +239,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -265,13 +268,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyTagFilter.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyTagFilter.Serialization.cs index 380889f6e1fd8..2861b2b39312e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyTagFilter.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyTagFilter.Serialization.cs @@ -117,21 +117,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -139,21 +139,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operator), out propertyOverride); if (Optional.IsDefined(Operator) || hasPropertyOverride) { - builder.Append(" op:"); + builder.Append(" op: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operator.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operator}'''"); } else { - builder.AppendLine($" '{Operator}'"); + builder.AppendLine($"'{Operator}'"); } } } @@ -161,21 +161,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyVersion.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyVersion.Serialization.cs index 37ed267279430..61503020ba677 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyVersion.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ManagementPolicyVersion.Serialization.cs @@ -106,7 +106,7 @@ internal static ManagementPolicyVersion DeserializeManagementPolicyVersion(JsonE { continue; } - tierToCool = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToCool = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToArchive"u8)) @@ -115,7 +115,7 @@ internal static ManagementPolicyVersion DeserializeManagementPolicyVersion(JsonE { continue; } - tierToArchive = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToArchive = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToCold"u8)) @@ -124,7 +124,7 @@ internal static ManagementPolicyVersion DeserializeManagementPolicyVersion(JsonE { continue; } - tierToCold = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToCold = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("tierToHot"u8)) @@ -133,7 +133,7 @@ internal static ManagementPolicyVersion DeserializeManagementPolicyVersion(JsonE { continue; } - tierToHot = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + tierToHot = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (property.NameEquals("delete"u8)) @@ -142,7 +142,7 @@ internal static ManagementPolicyVersion DeserializeManagementPolicyVersion(JsonE { continue; } - delete = DateAfterCreation.DeserializeDateAfterCreation(property.Value, options); + delete = DateAfterCreation.DeserializeDateAfterCreation(property.Value); continue; } if (options.Format != "W") @@ -168,70 +168,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCool), out propertyOverride); if (Optional.IsDefined(TierToCool) || hasPropertyOverride) { - builder.Append(" tierToCool:"); + builder.Append(" tierToCool: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCool, options, 2, false); + AppendChildObject(builder, TierToCool, options, 2, false, " tierToCool: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToArchive), out propertyOverride); if (Optional.IsDefined(TierToArchive) || hasPropertyOverride) { - builder.Append(" tierToArchive:"); + builder.Append(" tierToArchive: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToArchive, options, 2, false); + AppendChildObject(builder, TierToArchive, options, 2, false, " tierToArchive: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToCold), out propertyOverride); if (Optional.IsDefined(TierToCold) || hasPropertyOverride) { - builder.Append(" tierToCold:"); + builder.Append(" tierToCold: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToCold, options, 2, false); + AppendChildObject(builder, TierToCold, options, 2, false, " tierToCold: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TierToHot), out propertyOverride); if (Optional.IsDefined(TierToHot) || hasPropertyOverride) { - builder.Append(" tierToHot:"); + builder.Append(" tierToHot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TierToHot, options, 2, false); + AppendChildObject(builder, TierToHot, options, 2, false, " tierToHot: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Delete), out propertyOverride); if (Optional.IsDefined(Delete) || hasPropertyOverride) { - builder.Append(" delete:"); + builder.Append(" delete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Delete, options, 2, false); + AppendChildObject(builder, Delete, options, 2, false, " delete: "); } } @@ -239,12 +239,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -265,13 +268,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/Multichannel.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/Multichannel.Serialization.cs index 0bc4e9a6f0c5a..991714bf6d5c4 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/Multichannel.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/Multichannel.Serialization.cs @@ -108,15 +108,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMultiChannelEnabled), out propertyOverride); if (Optional.IsDefined(IsMultiChannelEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsMultiChannelEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicies.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicies.Serialization.cs index 6e6a84b60826f..cdfffbddcc0d4 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicies.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicies.Serialization.cs @@ -92,7 +92,7 @@ internal static ObjectReplicationPolicies DeserializeObjectReplicationPolicies(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ObjectReplicationPolicyData.DeserializeObjectReplicationPolicyData(item, options)); + array.Add(ObjectReplicationPolicyData.DeserializeObjectReplicationPolicyData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyFilter.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyFilter.Serialization.cs index 1b391d80c768f..503bb33b7dfb5 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyFilter.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyFilter.Serialization.cs @@ -132,14 +132,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrefixMatch.Any() || hasPropertyOverride) { - builder.Append(" prefixMatch:"); + builder.Append(" prefixMatch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrefixMatch) { if (item == null) @@ -165,21 +165,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCreationTime), out propertyOverride); if (Optional.IsDefined(MinCreationTime) || hasPropertyOverride) { - builder.Append(" minCreationTime:"); + builder.Append(" minCreationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MinCreationTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MinCreationTime}'''"); } else { - builder.AppendLine($" '{MinCreationTime}'"); + builder.AppendLine($"'{MinCreationTime}'"); } } } @@ -188,12 +188,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -214,13 +217,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyRule.Serialization.cs index 16bffac22c440..3e1a486655005 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ObjectReplicationPolicyRule.Serialization.cs @@ -109,7 +109,7 @@ internal static ObjectReplicationPolicyRule DeserializeObjectReplicationPolicyRu { continue; } - filters = ObjectReplicationPolicyFilter.DeserializeObjectReplicationPolicyFilter(property.Value, options); + filters = ObjectReplicationPolicyFilter.DeserializeObjectReplicationPolicyFilter(property.Value); continue; } if (options.Format != "W") @@ -135,21 +135,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleId), out propertyOverride); if (Optional.IsDefined(RuleId) || hasPropertyOverride) { - builder.Append(" ruleId:"); + builder.Append(" ruleId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuleId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuleId}'''"); } else { - builder.AppendLine($" '{RuleId}'"); + builder.AppendLine($"'{RuleId}'"); } } } @@ -157,21 +157,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceContainer), out propertyOverride); if (Optional.IsDefined(SourceContainer) || hasPropertyOverride) { - builder.Append(" sourceContainer:"); + builder.Append(" sourceContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceContainer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceContainer}'''"); } else { - builder.AppendLine($" '{SourceContainer}'"); + builder.AppendLine($"'{SourceContainer}'"); } } } @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DestinationContainer), out propertyOverride); if (Optional.IsDefined(DestinationContainer) || hasPropertyOverride) { - builder.Append(" destinationContainer:"); + builder.Append(" destinationContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DestinationContainer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DestinationContainer}'''"); } else { - builder.AppendLine($" '{DestinationContainer}'"); + builder.AppendLine($"'{DestinationContainer}'"); } } } @@ -201,14 +201,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Filters), out propertyOverride); if (Optional.IsDefined(Filters) || hasPropertyOverride) { - builder.Append(" filters:"); + builder.Append(" filters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Filters, options, 2, false); + AppendChildObject(builder, Filters, options, 2, false, " filters: "); } } @@ -216,12 +216,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -242,13 +245,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtectedAppendWritesHistory.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtectedAppendWritesHistory.Serialization.cs index fac2011fb1bca..4366dddb95c1a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtectedAppendWritesHistory.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtectedAppendWritesHistory.Serialization.cs @@ -123,30 +123,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWritesAll), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWritesAll) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWritesAll:"); + builder.Append(" allowProtectedAppendWritesAll: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWritesAll.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtocolSettings.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtocolSettings.Serialization.cs index a88c475671268..e6ef5ec921eaa 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtocolSettings.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/ProtocolSettings.Serialization.cs @@ -82,7 +82,7 @@ internal static ProtocolSettings DeserializeProtocolSettings(JsonElement element { continue; } - smb = SmbSetting.DeserializeSmbSetting(property.Value, options); + smb = SmbSetting.DeserializeSmbSetting(property.Value); continue; } if (options.Format != "W") @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SmbSetting), out propertyOverride); if (Optional.IsDefined(SmbSetting) || hasPropertyOverride) { - builder.Append(" smb:"); + builder.Append(" smb: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SmbSetting, options, 2, false); + AppendChildObject(builder, SmbSetting, options, 2, false, " smb: "); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/RestorePolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/RestorePolicy.Serialization.cs index b35a0014b9422..8b8cc1113dd55 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/RestorePolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/RestorePolicy.Serialization.cs @@ -146,59 +146,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Days), out propertyOverride); if (Optional.IsDefined(Days) || hasPropertyOverride) { - builder.Append(" days:"); + builder.Append(" days: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Days.Value}"); + builder.AppendLine($"{Days.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastEnabledOn), out propertyOverride); if (Optional.IsDefined(LastEnabledOn) || hasPropertyOverride) { - builder.Append(" lastEnabledTime:"); + builder.Append(" lastEnabledTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastEnabledOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinRestoreOn), out propertyOverride); if (Optional.IsDefined(MinRestoreOn) || hasPropertyOverride) { - builder.Append(" minRestoreTime:"); + builder.Append(" minRestoreTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(MinRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -206,12 +206,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -232,13 +235,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/SmbSetting.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/SmbSetting.Serialization.cs index fb3f6c9670ced..3a70575023c85 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/SmbSetting.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/SmbSetting.Serialization.cs @@ -106,7 +106,7 @@ internal static SmbSetting DeserializeSmbSetting(JsonElement element, ModelReade { continue; } - multichannel = Multichannel.DeserializeMultichannel(property.Value, options); + multichannel = Multichannel.DeserializeMultichannel(property.Value); continue; } if (property.NameEquals("versions"u8)) @@ -152,35 +152,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Multichannel), out propertyOverride); if (Optional.IsDefined(Multichannel) || hasPropertyOverride) { - builder.Append(" multichannel:"); + builder.Append(" multichannel: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Multichannel, options, 2, false); + AppendChildObject(builder, Multichannel, options, 2, false, " multichannel: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Versions), out propertyOverride); if (Optional.IsDefined(Versions) || hasPropertyOverride) { - builder.Append(" versions:"); + builder.Append(" versions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Versions.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Versions}'''"); } else { - builder.AppendLine($" '{Versions}'"); + builder.AppendLine($"'{Versions}'"); } } } @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthenticationMethods), out propertyOverride); if (Optional.IsDefined(AuthenticationMethods) || hasPropertyOverride) { - builder.Append(" authenticationMethods:"); + builder.Append(" authenticationMethods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthenticationMethods.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthenticationMethods}'''"); } else { - builder.AppendLine($" '{AuthenticationMethods}'"); + builder.AppendLine($"'{AuthenticationMethods}'"); } } } @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KerberosTicketEncryption), out propertyOverride); if (Optional.IsDefined(KerberosTicketEncryption) || hasPropertyOverride) { - builder.Append(" kerberosTicketEncryption:"); + builder.Append(" kerberosTicketEncryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KerberosTicketEncryption.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KerberosTicketEncryption}'''"); } else { - builder.AppendLine($" '{KerberosTicketEncryption}'"); + builder.AppendLine($"'{KerberosTicketEncryption}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChannelEncryption), out propertyOverride); if (Optional.IsDefined(ChannelEncryption) || hasPropertyOverride) { - builder.Append(" channelEncryption:"); + builder.Append(" channelEncryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ChannelEncryption.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ChannelEncryption}'''"); } else { - builder.AppendLine($" '{ChannelEncryption}'"); + builder.AppendLine($"'{ChannelEncryption}'"); } } } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs index eb069cd4079c6..26dc660709f8e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs @@ -247,7 +247,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { if (property.NameEquals("sku"u8)) { - sku = StorageSku.DeserializeStorageSku(property.Value, options); + sku = StorageSku.DeserializeStorageSku(property.Value); continue; } if (property.NameEquals("kind"u8)) @@ -326,7 +326,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value, options); + sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value); continue; } if (property0.NameEquals("keyPolicy"u8)) @@ -335,7 +335,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value, options); + keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value); continue; } if (property0.NameEquals("customDomain"u8)) @@ -344,7 +344,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value, options); + customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value); continue; } if (property0.NameEquals("encryption"u8)) @@ -353,7 +353,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value, options); + encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value); continue; } if (property0.NameEquals("networkAcls"u8)) @@ -362,7 +362,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value, options); + networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value); continue; } if (property0.NameEquals("accessTier"u8)) @@ -380,7 +380,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value, options); + azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value); continue; } if (property0.NameEquals("supportsHttpsTrafficOnly"u8)) @@ -434,7 +434,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value, options); + routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value); continue; } if (property0.NameEquals("allowBlobPublicAccess"u8)) @@ -497,7 +497,7 @@ internal static StorageAccountCreateOrUpdateContent DeserializeStorageAccountCre { continue; } - immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value, options); + immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value); continue; } if (property0.NameEquals("dnsEndpointType"u8)) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryption.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryption.Serialization.cs index eb0dfdf21547e..f249c805fd3da 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryption.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryption.Serialization.cs @@ -106,7 +106,7 @@ internal static StorageAccountEncryption DeserializeStorageAccountEncryption(Jso { continue; } - services = StorageAccountEncryptionServices.DeserializeStorageAccountEncryptionServices(property.Value, options); + services = StorageAccountEncryptionServices.DeserializeStorageAccountEncryptionServices(property.Value); continue; } if (property.NameEquals("keySource"u8)) @@ -133,7 +133,7 @@ internal static StorageAccountEncryption DeserializeStorageAccountEncryption(Jso { continue; } - keyvaultproperties = StorageAccountKeyVaultProperties.DeserializeStorageAccountKeyVaultProperties(property.Value, options); + keyvaultproperties = StorageAccountKeyVaultProperties.DeserializeStorageAccountKeyVaultProperties(property.Value); continue; } if (property.NameEquals("identity"u8)) @@ -142,7 +142,7 @@ internal static StorageAccountEncryption DeserializeStorageAccountEncryption(Jso { continue; } - identity = StorageAccountEncryptionIdentity.DeserializeStorageAccountEncryptionIdentity(property.Value, options); + identity = StorageAccountEncryptionIdentity.DeserializeStorageAccountEncryptionIdentity(property.Value); continue; } if (options.Format != "W") @@ -168,71 +168,71 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Services), out propertyOverride); if (Optional.IsDefined(Services) || hasPropertyOverride) { - builder.Append(" services:"); + builder.Append(" services: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Services, options, 2, false); + AppendChildObject(builder, Services, options, 2, false, " services: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySource), out propertyOverride); if (Optional.IsDefined(KeySource) || hasPropertyOverride) { - builder.Append(" keySource:"); + builder.Append(" keySource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeySource.Value.ToString()}'"); + builder.AppendLine($"'{KeySource.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequireInfrastructureEncryption), out propertyOverride); if (Optional.IsDefined(RequireInfrastructureEncryption) || hasPropertyOverride) { - builder.Append(" requireInfrastructureEncryption:"); + builder.Append(" requireInfrastructureEncryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = RequireInfrastructureEncryption.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) { - builder.Append(" keyvaultproperties:"); + builder.Append(" keyvaultproperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyVaultProperties, options, 2, false); + AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyvaultproperties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncryptionIdentity), out propertyOverride); if (Optional.IsDefined(EncryptionIdentity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, EncryptionIdentity, options, 2, false); + AppendChildObject(builder, EncryptionIdentity, options, 2, false, " identity: "); } } @@ -240,12 +240,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -266,13 +269,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionIdentity.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionIdentity.Serialization.cs index 4d2848fec58c9..60f186b7ab3fc 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionIdentity.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionIdentity.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncryptionUserAssignedIdentity), out propertyOverride); if (Optional.IsDefined(EncryptionUserAssignedIdentity) || hasPropertyOverride) { - builder.Append(" userAssignedIdentity:"); + builder.Append(" userAssignedIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EncryptionUserAssignedIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EncryptionUserAssignedIdentity}'''"); } else { - builder.AppendLine($" '{EncryptionUserAssignedIdentity}'"); + builder.AppendLine($"'{EncryptionUserAssignedIdentity}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncryptionFederatedIdentityClientId), out propertyOverride); if (Optional.IsDefined(EncryptionFederatedIdentityClientId) || hasPropertyOverride) { - builder.Append(" federatedIdentityClientId:"); + builder.Append(" federatedIdentityClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EncryptionFederatedIdentityClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EncryptionFederatedIdentityClientId}'''"); } else { - builder.AppendLine($" '{EncryptionFederatedIdentityClientId}'"); + builder.AppendLine($"'{EncryptionFederatedIdentityClientId}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionServices.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionServices.Serialization.cs index df49bbf894dc6..6a14a6f8f3ddc 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionServices.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEncryptionServices.Serialization.cs @@ -100,7 +100,7 @@ internal static StorageAccountEncryptionServices DeserializeStorageAccountEncryp { continue; } - blob = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value, options); + blob = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value); continue; } if (property.NameEquals("file"u8)) @@ -109,7 +109,7 @@ internal static StorageAccountEncryptionServices DeserializeStorageAccountEncryp { continue; } - file = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value, options); + file = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value); continue; } if (property.NameEquals("table"u8)) @@ -118,7 +118,7 @@ internal static StorageAccountEncryptionServices DeserializeStorageAccountEncryp { continue; } - table = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value, options); + table = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value); continue; } if (property.NameEquals("queue"u8)) @@ -127,7 +127,7 @@ internal static StorageAccountEncryptionServices DeserializeStorageAccountEncryp { continue; } - queue = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value, options); + queue = StorageEncryptionService.DeserializeStorageEncryptionService(property.Value); continue; } if (options.Format != "W") @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Blob), out propertyOverride); if (Optional.IsDefined(Blob) || hasPropertyOverride) { - builder.Append(" blob:"); + builder.Append(" blob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Blob, options, 2, false); + AppendChildObject(builder, Blob, options, 2, false, " blob: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(File), out propertyOverride); if (Optional.IsDefined(File) || hasPropertyOverride) { - builder.Append(" file:"); + builder.Append(" file: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, File, options, 2, false); + AppendChildObject(builder, File, options, 2, false, " file: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Table), out propertyOverride); if (Optional.IsDefined(Table) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Table, options, 2, false); + AppendChildObject(builder, Table, options, 2, false, " table: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Queue), out propertyOverride); if (Optional.IsDefined(Queue) || hasPropertyOverride) { - builder.Append(" queue:"); + builder.Append(" queue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Queue, options, 2, false); + AppendChildObject(builder, Queue, options, 2, false, " queue: "); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEndpoints.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEndpoints.Serialization.cs index 06bce2afed7e1..0cc40c5e03146 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEndpoints.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountEndpoints.Serialization.cs @@ -178,7 +178,7 @@ internal static StorageAccountEndpoints DeserializeStorageAccountEndpoints(JsonE { continue; } - microsoftEndpoints = StorageAccountMicrosoftEndpoints.DeserializeStorageAccountMicrosoftEndpoints(property.Value, options); + microsoftEndpoints = StorageAccountMicrosoftEndpoints.DeserializeStorageAccountMicrosoftEndpoints(property.Value); continue; } if (property.NameEquals("internetEndpoints"u8)) @@ -187,7 +187,7 @@ internal static StorageAccountEndpoints DeserializeStorageAccountEndpoints(JsonE { continue; } - internetEndpoints = StorageAccountInternetEndpoints.DeserializeStorageAccountInternetEndpoints(property.Value, options); + internetEndpoints = StorageAccountInternetEndpoints.DeserializeStorageAccountInternetEndpoints(property.Value); continue; } if (options.Format != "W") @@ -213,112 +213,112 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobUri), out propertyOverride); if (Optional.IsDefined(BlobUri) || hasPropertyOverride) { - builder.Append(" blob:"); + builder.Append(" blob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BlobUri.AbsoluteUri}'"); + builder.AppendLine($"'{BlobUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueUri), out propertyOverride); if (Optional.IsDefined(QueueUri) || hasPropertyOverride) { - builder.Append(" queue:"); + builder.Append(" queue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{QueueUri.AbsoluteUri}'"); + builder.AppendLine($"'{QueueUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableUri), out propertyOverride); if (Optional.IsDefined(TableUri) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TableUri.AbsoluteUri}'"); + builder.AppendLine($"'{TableUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileUri), out propertyOverride); if (Optional.IsDefined(FileUri) || hasPropertyOverride) { - builder.Append(" file:"); + builder.Append(" file: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FileUri.AbsoluteUri}'"); + builder.AppendLine($"'{FileUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebUri), out propertyOverride); if (Optional.IsDefined(WebUri) || hasPropertyOverride) { - builder.Append(" web:"); + builder.Append(" web: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebUri.AbsoluteUri}'"); + builder.AppendLine($"'{WebUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DfsUri), out propertyOverride); if (Optional.IsDefined(DfsUri) || hasPropertyOverride) { - builder.Append(" dfs:"); + builder.Append(" dfs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DfsUri.AbsoluteUri}'"); + builder.AppendLine($"'{DfsUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MicrosoftEndpoints), out propertyOverride); if (Optional.IsDefined(MicrosoftEndpoints) || hasPropertyOverride) { - builder.Append(" microsoftEndpoints:"); + builder.Append(" microsoftEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MicrosoftEndpoints, options, 2, false); + AppendChildObject(builder, MicrosoftEndpoints, options, 2, false, " microsoftEndpoints: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternetEndpoints), out propertyOverride); if (Optional.IsDefined(InternetEndpoints) || hasPropertyOverride) { - builder.Append(" internetEndpoints:"); + builder.Append(" internetEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, InternetEndpoints, options, 2, false); + AppendChildObject(builder, InternetEndpoints, options, 2, false, " internetEndpoints: "); } } @@ -326,12 +326,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -352,13 +355,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountGetKeysResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountGetKeysResult.Serialization.cs index 818969d991036..21a6c4ebde4a2 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountGetKeysResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountGetKeysResult.Serialization.cs @@ -91,7 +91,7 @@ internal static StorageAccountGetKeysResult DeserializeStorageAccountGetKeysResu List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountKey.DeserializeStorageAccountKey(item, options)); + array.Add(StorageAccountKey.DeserializeStorageAccountKey(item)); } keys = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Keys.Any() || hasPropertyOverride) { - builder.Append(" keys:"); + builder.Append(" keys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Keys) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " keys: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountIPRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountIPRule.Serialization.cs index e164f926840b4..f4dbe080bd01c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountIPRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountIPRule.Serialization.cs @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPAddressOrRange), out propertyOverride); if (Optional.IsDefined(IPAddressOrRange) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (IPAddressOrRange.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{IPAddressOrRange}'''"); } else { - builder.AppendLine($" '{IPAddressOrRange}'"); + builder.AppendLine($"'{IPAddressOrRange}'"); } } } @@ -138,14 +138,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); if (Optional.IsDefined(Action) || hasPropertyOverride) { - builder.Append(" action:"); + builder.Append(" action: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Action.Value.ToString()}'"); + builder.AppendLine($"'{Action.Value.ToString()}'"); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountInternetEndpoints.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountInternetEndpoints.Serialization.cs index d3003d0c83c09..ef318d9efbb9a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountInternetEndpoints.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountInternetEndpoints.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobUri), out propertyOverride); if (Optional.IsDefined(BlobUri) || hasPropertyOverride) { - builder.Append(" blob:"); + builder.Append(" blob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BlobUri.AbsoluteUri}'"); + builder.AppendLine($"'{BlobUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileUri), out propertyOverride); if (Optional.IsDefined(FileUri) || hasPropertyOverride) { - builder.Append(" file:"); + builder.Append(" file: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FileUri.AbsoluteUri}'"); + builder.AppendLine($"'{FileUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebUri), out propertyOverride); if (Optional.IsDefined(WebUri) || hasPropertyOverride) { - builder.Append(" web:"); + builder.Append(" web: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebUri.AbsoluteUri}'"); + builder.AppendLine($"'{WebUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DfsUri), out propertyOverride); if (Optional.IsDefined(DfsUri) || hasPropertyOverride) { - builder.Append(" dfs:"); + builder.Append(" dfs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DfsUri.AbsoluteUri}'"); + builder.AppendLine($"'{DfsUri.AbsoluteUri}'"); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKey.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKey.Serialization.cs index 82697f4b0e320..c652ee2725b36 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKey.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKey.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyName), out propertyOverride); if (Optional.IsDefined(KeyName) || hasPropertyOverride) { - builder.Append(" keyName:"); + builder.Append(" keyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyName}'''"); } else { - builder.AppendLine($" '{KeyName}'"); + builder.AppendLine($"'{KeyName}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -189,29 +189,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permissions), out propertyOverride); if (Optional.IsDefined(Permissions) || hasPropertyOverride) { - builder.Append(" permissions:"); + builder.Append(" permissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Permissions.Value.ToSerialString()}'"); + builder.AppendLine($"'{Permissions.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -219,12 +219,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -245,13 +248,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyCreationTime.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyCreationTime.Serialization.cs index 93d8cd212258d..2d7b2db74052c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyCreationTime.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyCreationTime.Serialization.cs @@ -123,30 +123,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key1), out propertyOverride); if (Optional.IsDefined(Key1) || hasPropertyOverride) { - builder.Append(" key1:"); + builder.Append(" key1: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Key1.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key2), out propertyOverride); if (Optional.IsDefined(Key2) || hasPropertyOverride) { - builder.Append(" key2:"); + builder.Append(" key2: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Key2.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyPolicy.Serialization.cs index 76bd308c66254..ceb73ceac7fab 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyPolicy.Serialization.cs @@ -101,14 +101,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyExpirationPeriodInDays), out propertyOverride); if (Optional.IsDefined(KeyExpirationPeriodInDays) || hasPropertyOverride) { - builder.Append(" keyExpirationPeriodInDays:"); + builder.Append(" keyExpirationPeriodInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {KeyExpirationPeriodInDays}"); + builder.AppendLine($"{KeyExpirationPeriodInDays}"); } } @@ -116,12 +116,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -142,13 +145,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyVaultProperties.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyVaultProperties.Serialization.cs index 25ff0b568329e..13ec76a25954a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyVaultProperties.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountKeyVaultProperties.Serialization.cs @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyName), out propertyOverride); if (Optional.IsDefined(KeyName) || hasPropertyOverride) { - builder.Append(" keyname:"); + builder.Append(" keyname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyName}'''"); } else { - builder.AppendLine($" '{KeyName}'"); + builder.AppendLine($"'{KeyName}'"); } } } @@ -193,21 +193,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVersion), out propertyOverride); if (Optional.IsDefined(KeyVersion) || hasPropertyOverride) { - builder.Append(" keyversion:"); + builder.Append(" keyversion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVersion}'''"); } else { - builder.AppendLine($" '{KeyVersion}'"); + builder.AppendLine($"'{KeyVersion}'"); } } } @@ -215,35 +215,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultUri), out propertyOverride); if (Optional.IsDefined(KeyVaultUri) || hasPropertyOverride) { - builder.Append(" keyvaulturi:"); + builder.Append(" keyvaulturi: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultUri.AbsoluteUri}'"); + builder.AppendLine($"'{KeyVaultUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentVersionedKeyIdentifier), out propertyOverride); if (Optional.IsDefined(CurrentVersionedKeyIdentifier) || hasPropertyOverride) { - builder.Append(" currentVersionedKeyIdentifier:"); + builder.Append(" currentVersionedKeyIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CurrentVersionedKeyIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CurrentVersionedKeyIdentifier}'''"); } else { - builder.AppendLine($" '{CurrentVersionedKeyIdentifier}'"); + builder.AppendLine($"'{CurrentVersionedKeyIdentifier}'"); } } } @@ -251,30 +251,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastKeyRotationTimestamp), out propertyOverride); if (Optional.IsDefined(LastKeyRotationTimestamp) || hasPropertyOverride) { - builder.Append(" lastKeyRotationTimestamp:"); + builder.Append(" lastKeyRotationTimestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastKeyRotationTimestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentVersionedKeyExpirationTimestamp), out propertyOverride); if (Optional.IsDefined(CurrentVersionedKeyExpirationTimestamp) || hasPropertyOverride) { - builder.Append(" currentVersionedKeyExpirationTimestamp:"); + builder.Append(" currentVersionedKeyExpirationTimestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CurrentVersionedKeyExpirationTimestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -282,12 +282,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -308,13 +311,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountListResult.Serialization.cs index 0fcc6942df1e0..4af47c4c21a99 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountListResult.Serialization.cs @@ -98,7 +98,7 @@ internal static StorageAccountListResult DeserializeStorageAccountListResult(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountData.DeserializeStorageAccountData(item, options)); + array.Add(StorageAccountData.DeserializeStorageAccountData(item)); } value = array; continue; @@ -133,17 +133,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -153,21 +153,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -176,12 +176,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -202,13 +205,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountMicrosoftEndpoints.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountMicrosoftEndpoints.Serialization.cs index dce2e87e29eb9..559152500dc40 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountMicrosoftEndpoints.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountMicrosoftEndpoints.Serialization.cs @@ -183,84 +183,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobUri), out propertyOverride); if (Optional.IsDefined(BlobUri) || hasPropertyOverride) { - builder.Append(" blob:"); + builder.Append(" blob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BlobUri.AbsoluteUri}'"); + builder.AppendLine($"'{BlobUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueUri), out propertyOverride); if (Optional.IsDefined(QueueUri) || hasPropertyOverride) { - builder.Append(" queue:"); + builder.Append(" queue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{QueueUri.AbsoluteUri}'"); + builder.AppendLine($"'{QueueUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableUri), out propertyOverride); if (Optional.IsDefined(TableUri) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TableUri.AbsoluteUri}'"); + builder.AppendLine($"'{TableUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileUri), out propertyOverride); if (Optional.IsDefined(FileUri) || hasPropertyOverride) { - builder.Append(" file:"); + builder.Append(" file: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FileUri.AbsoluteUri}'"); + builder.AppendLine($"'{FileUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebUri), out propertyOverride); if (Optional.IsDefined(WebUri) || hasPropertyOverride) { - builder.Append(" web:"); + builder.Append(" web: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebUri.AbsoluteUri}'"); + builder.AppendLine($"'{WebUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DfsUri), out propertyOverride); if (Optional.IsDefined(DfsUri) || hasPropertyOverride) { - builder.Append(" dfs:"); + builder.Append(" dfs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DfsUri.AbsoluteUri}'"); + builder.AppendLine($"'{DfsUri.AbsoluteUri}'"); } } @@ -268,12 +268,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -294,13 +297,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNameAvailabilityResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNameAvailabilityResult.Serialization.cs index 94e26c978c1ea..32edafeb4ee96 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNameAvailabilityResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNameAvailabilityResult.Serialization.cs @@ -134,50 +134,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsNameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToSerialString()}'"); + builder.AppendLine($"'{Reason.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNetworkRuleSet.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNetworkRuleSet.Serialization.cs index 0a230ef15a901..e795b87d692f4 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNetworkRuleSet.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountNetworkRuleSet.Serialization.cs @@ -131,7 +131,7 @@ internal static StorageAccountNetworkRuleSet DeserializeStorageAccountNetworkRul List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountResourceAccessRule.DeserializeStorageAccountResourceAccessRule(item, options)); + array.Add(StorageAccountResourceAccessRule.DeserializeStorageAccountResourceAccessRule(item)); } resourceAccessRules = array; continue; @@ -145,7 +145,7 @@ internal static StorageAccountNetworkRuleSet DeserializeStorageAccountNetworkRul List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountVirtualNetworkRule.DeserializeStorageAccountVirtualNetworkRule(item, options)); + array.Add(StorageAccountVirtualNetworkRule.DeserializeStorageAccountVirtualNetworkRule(item)); } virtualNetworkRules = array; continue; @@ -159,7 +159,7 @@ internal static StorageAccountNetworkRuleSet DeserializeStorageAccountNetworkRul List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageAccountIPRule.DeserializeStorageAccountIPRule(item, options)); + array.Add(StorageAccountIPRule.DeserializeStorageAccountIPRule(item)); } ipRules = array; continue; @@ -192,14 +192,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Bypass), out propertyOverride); if (Optional.IsDefined(Bypass) || hasPropertyOverride) { - builder.Append(" bypass:"); + builder.Append(" bypass: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Bypass.Value.ToString()}'"); + builder.AppendLine($"'{Bypass.Value.ToString()}'"); } } @@ -208,17 +208,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ResourceAccessRules.Any() || hasPropertyOverride) { - builder.Append(" resourceAccessRules:"); + builder.Append(" resourceAccessRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ResourceAccessRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " resourceAccessRules: "); } builder.AppendLine(" ]"); } @@ -230,17 +230,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualNetworkRules.Any() || hasPropertyOverride) { - builder.Append(" virtualNetworkRules:"); + builder.Append(" virtualNetworkRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualNetworkRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " virtualNetworkRules: "); } builder.AppendLine(" ]"); } @@ -252,17 +252,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPRules.Any() || hasPropertyOverride) { - builder.Append(" ipRules:"); + builder.Append(" ipRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " ipRules: "); } builder.AppendLine(" ]"); } @@ -272,14 +272,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAction), out propertyOverride); if (Optional.IsDefined(DefaultAction) || hasPropertyOverride) { - builder.Append(" defaultAction:"); + builder.Append(" defaultAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultAction.ToSerialString()}'"); + builder.AppendLine($"'{DefaultAction.ToSerialString()}'"); } } @@ -287,12 +287,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -313,13 +316,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs index 0a9a79861e10f..8eeac1eb7d565 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs @@ -235,7 +235,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - sku = StorageSku.DeserializeStorageSku(property.Value, options); + sku = StorageSku.DeserializeStorageSku(property.Value); continue; } if (property.NameEquals("tags"u8)) @@ -286,7 +286,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value, options); + customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value); continue; } if (property0.NameEquals("encryption"u8)) @@ -295,7 +295,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value, options); + encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value); continue; } if (property0.NameEquals("sasPolicy"u8)) @@ -304,7 +304,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value, options); + sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value); continue; } if (property0.NameEquals("keyPolicy"u8)) @@ -313,7 +313,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value, options); + keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value); continue; } if (property0.NameEquals("accessTier"u8)) @@ -331,7 +331,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value, options); + azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value); continue; } if (property0.NameEquals("supportsHttpsTrafficOnly"u8)) @@ -367,7 +367,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value, options); + networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value); continue; } if (property0.NameEquals("largeFileSharesState"u8)) @@ -385,7 +385,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value, options); + routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value); continue; } if (property0.NameEquals("allowBlobPublicAccess"u8)) @@ -448,7 +448,7 @@ internal static StorageAccountPatch DeserializeStorageAccountPatch(JsonElement e { continue; } - immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value, options); + immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value); continue; } if (property0.NameEquals("allowedCopyScope"u8)) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountResourceAccessRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountResourceAccessRule.Serialization.cs index 14ab92eea4496..55a7361cf1b97 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountResourceAccessRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountResourceAccessRule.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); if (Optional.IsDefined(ResourceId) || hasPropertyOverride) { - builder.Append(" resourceId:"); + builder.Append(" resourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceId.ToString()}'"); + builder.AppendLine($"'{ResourceId.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSasPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSasPolicy.Serialization.cs index 169c7454d6137..4dbe3b0dd9a4d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSasPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSasPolicy.Serialization.cs @@ -109,21 +109,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasExpirationPeriod), out propertyOverride); if (Optional.IsDefined(SasExpirationPeriod) || hasPropertyOverride) { - builder.Append(" sasExpirationPeriod:"); + builder.Append(" sasExpirationPeriod: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SasExpirationPeriod.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SasExpirationPeriod}'''"); } else { - builder.AppendLine($" '{SasExpirationPeriod}'"); + builder.AppendLine($"'{SasExpirationPeriod}'"); } } } @@ -131,14 +131,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpirationAction), out propertyOverride); if (Optional.IsDefined(ExpirationAction) || hasPropertyOverride) { - builder.Append(" expirationAction:"); + builder.Append(" expirationAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExpirationAction.ToString()}'"); + builder.AppendLine($"'{ExpirationAction.ToString()}'"); } } @@ -146,12 +146,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -172,13 +175,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSkuConversionStatus.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSkuConversionStatus.Serialization.cs index 72304b64994bf..2bf8f1c89096f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSkuConversionStatus.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountSkuConversionStatus.Serialization.cs @@ -153,58 +153,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkuConversionStatus), out propertyOverride); if (Optional.IsDefined(SkuConversionStatus) || hasPropertyOverride) { - builder.Append(" skuConversionStatus:"); + builder.Append(" skuConversionStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SkuConversionStatus.Value.ToString()}'"); + builder.AppendLine($"'{SkuConversionStatus.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetSkuName), out propertyOverride); if (Optional.IsDefined(TargetSkuName) || hasPropertyOverride) { - builder.Append(" targetSkuName:"); + builder.Append(" targetSkuName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetSkuName.Value.ToString()}'"); + builder.AppendLine($"'{TargetSkuName.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -212,12 +212,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -238,13 +241,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountVirtualNetworkRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountVirtualNetworkRule.Serialization.cs index 105307985c8bb..5c85ab9fd3806 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountVirtualNetworkRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageAccountVirtualNetworkRule.Serialization.cs @@ -131,42 +131,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkResourceId), out propertyOverride); if (Optional.IsDefined(VirtualNetworkResourceId) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VirtualNetworkResourceId.ToString()}'"); + builder.AppendLine($"'{VirtualNetworkResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); if (Optional.IsDefined(Action) || hasPropertyOverride) { - builder.Append(" action:"); + builder.Append(" action: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Action.Value.ToString()}'"); + builder.AppendLine($"'{Action.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToString()}'"); + builder.AppendLine($"'{State.Value.ToString()}'"); } } @@ -174,12 +174,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -200,13 +203,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageActiveDirectoryProperties.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageActiveDirectoryProperties.Serialization.cs index adf13fe555bef..0b9d597eeb77e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageActiveDirectoryProperties.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageActiveDirectoryProperties.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainName), out propertyOverride); if (Optional.IsDefined(DomainName) || hasPropertyOverride) { - builder.Append(" domainName:"); + builder.Append(" domainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainName}'''"); } else { - builder.AppendLine($" '{DomainName}'"); + builder.AppendLine($"'{DomainName}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetBiosDomainName), out propertyOverride); if (Optional.IsDefined(NetBiosDomainName) || hasPropertyOverride) { - builder.Append(" netBiosDomainName:"); + builder.Append(" netBiosDomainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NetBiosDomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NetBiosDomainName}'''"); } else { - builder.AppendLine($" '{NetBiosDomainName}'"); + builder.AppendLine($"'{NetBiosDomainName}'"); } } } @@ -223,21 +223,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForestName), out propertyOverride); if (Optional.IsDefined(ForestName) || hasPropertyOverride) { - builder.Append(" forestName:"); + builder.Append(" forestName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ForestName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ForestName}'''"); } else { - builder.AppendLine($" '{ForestName}'"); + builder.AppendLine($"'{ForestName}'"); } } } @@ -245,35 +245,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainGuid), out propertyOverride); if (Optional.IsDefined(DomainGuid) || hasPropertyOverride) { - builder.Append(" domainGuid:"); + builder.Append(" domainGuid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DomainGuid.ToString()}'"); + builder.AppendLine($"'{DomainGuid.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainSid), out propertyOverride); if (Optional.IsDefined(DomainSid) || hasPropertyOverride) { - builder.Append(" domainSid:"); + builder.Append(" domainSid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainSid.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainSid}'''"); } else { - builder.AppendLine($" '{DomainSid}'"); + builder.AppendLine($"'{DomainSid}'"); } } } @@ -281,21 +281,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureStorageSid), out propertyOverride); if (Optional.IsDefined(AzureStorageSid) || hasPropertyOverride) { - builder.Append(" azureStorageSid:"); + builder.Append(" azureStorageSid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzureStorageSid.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzureStorageSid}'''"); } else { - builder.AppendLine($" '{AzureStorageSid}'"); + builder.AppendLine($"'{AzureStorageSid}'"); } } } @@ -303,21 +303,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SamAccountName), out propertyOverride); if (Optional.IsDefined(SamAccountName) || hasPropertyOverride) { - builder.Append(" samAccountName:"); + builder.Append(" samAccountName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SamAccountName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SamAccountName}'''"); } else { - builder.AppendLine($" '{SamAccountName}'"); + builder.AppendLine($"'{SamAccountName}'"); } } } @@ -325,14 +325,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccountType), out propertyOverride); if (Optional.IsDefined(AccountType) || hasPropertyOverride) { - builder.Append(" accountType:"); + builder.Append(" accountType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AccountType.Value.ToString()}'"); + builder.AppendLine($"'{AccountType.Value.ToString()}'"); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRule.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRule.Serialization.cs index 663fe93225890..879426d983aa7 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRule.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRule.Serialization.cs @@ -176,14 +176,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedOrigins.Any() || hasPropertyOverride) { - builder.Append(" allowedOrigins:"); + builder.Append(" allowedOrigins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedOrigins) { if (item == null) @@ -211,14 +211,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedMethods.Any() || hasPropertyOverride) { - builder.Append(" allowedMethods:"); + builder.Append(" allowedMethods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedMethods) { builder.AppendLine($" '{item.ToString()}'"); @@ -231,14 +231,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxAgeInSeconds), out propertyOverride); if (Optional.IsDefined(MaxAgeInSeconds) || hasPropertyOverride) { - builder.Append(" maxAgeInSeconds:"); + builder.Append(" maxAgeInSeconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxAgeInSeconds}"); + builder.AppendLine($"{MaxAgeInSeconds}"); } } @@ -247,14 +247,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExposedHeaders.Any() || hasPropertyOverride) { - builder.Append(" exposedHeaders:"); + builder.Append(" exposedHeaders: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExposedHeaders) { if (item == null) @@ -282,14 +282,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedHeaders.Any() || hasPropertyOverride) { - builder.Append(" allowedHeaders:"); + builder.Append(" allowedHeaders: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedHeaders) { if (item == null) @@ -316,12 +316,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -342,13 +345,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRules.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRules.Serialization.cs index b96b8a8affffa..9947ff756556c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRules.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCorsRules.Serialization.cs @@ -91,7 +91,7 @@ internal static StorageCorsRules DeserializeStorageCorsRules(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageCorsRule.DeserializeStorageCorsRule(item, options)); + array.Add(StorageCorsRule.DeserializeStorageCorsRule(item)); } corsRules = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CorsRules.Any() || hasPropertyOverride) { - builder.Append(" corsRules:"); + builder.Append(" corsRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CorsRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " corsRules: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCustomDomain.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCustomDomain.Serialization.cs index a37acd9865357..65e8dc2c6a26c 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCustomDomain.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageCustomDomain.Serialization.cs @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -138,15 +138,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUseSubDomainNameEnabled), out propertyOverride); if (Optional.IsDefined(IsUseSubDomainNameEnabled) || hasPropertyOverride) { - builder.Append(" useSubDomainName:"); + builder.Append(" useSubDomainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUseSubDomainNameEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageEncryptionService.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageEncryptionService.Serialization.cs index 72d514be53918..23977b52ad0b6 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageEncryptionService.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageEncryptionService.Serialization.cs @@ -138,44 +138,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastEnabledOn), out propertyOverride); if (Optional.IsDefined(LastEnabledOn) || hasPropertyOverride) { - builder.Append(" lastEnabledTime:"); + builder.Append(" lastEnabledTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastEnabledOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyType), out propertyOverride); if (Optional.IsDefined(KeyType) || hasPropertyOverride) { - builder.Append(" keyType:"); + builder.Append(" keyType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyType.Value.ToString()}'"); + builder.AppendLine($"'{KeyType.Value.ToString()}'"); } } @@ -183,12 +183,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -209,13 +212,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePermissionScope.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePermissionScope.Serialization.cs index 5e900222d948e..0dcb4e9d2b993 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePermissionScope.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePermissionScope.Serialization.cs @@ -117,21 +117,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permissions), out propertyOverride); if (Optional.IsDefined(Permissions) || hasPropertyOverride) { - builder.Append(" permissions:"); + builder.Append(" permissions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Permissions.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Permissions}'''"); } else { - builder.AppendLine($" '{Permissions}'"); + builder.AppendLine($"'{Permissions}'"); } } } @@ -139,21 +139,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Service), out propertyOverride); if (Optional.IsDefined(Service) || hasPropertyOverride) { - builder.Append(" service:"); + builder.Append(" service: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Service.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Service}'''"); } else { - builder.AppendLine($" '{Service}'"); + builder.AppendLine($"'{Service}'"); } } } @@ -161,21 +161,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateEndpointConnectionListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateEndpointConnectionListResult.Serialization.cs index 58346da308b29..89f30d82154ef 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateEndpointConnectionListResult.Serialization.cs @@ -92,7 +92,7 @@ internal static StoragePrivateEndpointConnectionListResult DeserializeStoragePri List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StoragePrivateEndpointConnectionData.DeserializeStoragePrivateEndpointConnectionData(item, options)); + array.Add(StoragePrivateEndpointConnectionData.DeserializeStoragePrivateEndpointConnectionData(item)); } value = array; continue; @@ -122,17 +122,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,12 +143,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -169,13 +172,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceData.Serialization.cs index 506eb4b9efe64..f2a3f68060b75 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceData.Serialization.cs @@ -223,21 +223,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -245,28 +245,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -275,14 +275,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{GroupId.ToString()}'"); + builder.AppendLine($"'{GroupId.ToString()}'"); } } @@ -291,14 +291,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -326,14 +326,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -361,12 +361,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -387,13 +390,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceListResult.Serialization.cs index 302f179e3a544..4b7a2f1079430 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkResourceListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static StoragePrivateLinkResourceListResult DeserializeStoragePrivateLi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StoragePrivateLinkResourceData.DeserializeStoragePrivateLinkResourceData(item, options)); + array.Add(StoragePrivateLinkResourceData.DeserializeStoragePrivateLinkResourceData(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkServiceConnectionState.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkServiceConnectionState.Serialization.cs index c5e609c4d073c..4c896b4c6cc8e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StoragePrivateLinkServiceConnectionState.Serialization.cs @@ -130,35 +130,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -166,21 +166,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionRequired), out propertyOverride); if (Optional.IsDefined(ActionRequired) || hasPropertyOverride) { - builder.Append(" actionRequired:"); + builder.Append(" actionRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionRequired.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionRequired}'''"); } else { - builder.AppendLine($" '{ActionRequired}'"); + builder.AppendLine($"'{ActionRequired}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageRoutingPreference.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageRoutingPreference.Serialization.cs index 53b9fcc6a529a..d1fc19f2b57f8 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageRoutingPreference.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageRoutingPreference.Serialization.cs @@ -138,44 +138,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoutingChoice), out propertyOverride); if (Optional.IsDefined(RoutingChoice) || hasPropertyOverride) { - builder.Append(" routingChoice:"); + builder.Append(" routingChoice: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RoutingChoice.Value.ToString()}'"); + builder.AppendLine($"'{RoutingChoice.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMicrosoftEndpointsPublished), out propertyOverride); if (Optional.IsDefined(IsMicrosoftEndpointsPublished) || hasPropertyOverride) { - builder.Append(" publishMicrosoftEndpoints:"); + builder.Append(" publishMicrosoftEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsMicrosoftEndpointsPublished.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInternetEndpointsPublished), out propertyOverride); if (Optional.IsDefined(IsInternetEndpointsPublished) || hasPropertyOverride) { - builder.Append(" publishInternetEndpoints:"); + builder.Append(" publishInternetEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInternetEndpointsPublished.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -183,12 +183,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -209,13 +212,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageServiceAccessPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageServiceAccessPolicy.Serialization.cs index 2b16ad92928ae..ac160bc6b0792 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageServiceAccessPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageServiceAccessPolicy.Serialization.cs @@ -134,51 +134,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expiryTime:"); + builder.Append(" expiryTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permission), out propertyOverride); if (Optional.IsDefined(Permission) || hasPropertyOverride) { - builder.Append(" permission:"); + builder.Append(" permission: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Permission.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Permission}'''"); } else { - builder.AppendLine($" '{Permission}'"); + builder.AppendLine($"'{Permission}'"); } } } @@ -187,12 +187,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -213,13 +216,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSignedIdentifier.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSignedIdentifier.Serialization.cs index 19bc9933f5a23..9187ada380478 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSignedIdentifier.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSignedIdentifier.Serialization.cs @@ -93,7 +93,7 @@ internal static StorageSignedIdentifier DeserializeStorageSignedIdentifier(JsonE { continue; } - accessPolicy = StorageServiceAccessPolicy.DeserializeStorageServiceAccessPolicy(property.Value, options); + accessPolicy = StorageServiceAccessPolicy.DeserializeStorageServiceAccessPolicy(property.Value); continue; } if (options.Format != "W") @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessPolicy), out propertyOverride); if (Optional.IsDefined(AccessPolicy) || hasPropertyOverride) { - builder.Append(" accessPolicy:"); + builder.Append(" accessPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AccessPolicy, options, 2, false); + AppendChildObject(builder, AccessPolicy, options, 2, false, " accessPolicy: "); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSku.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSku.Serialization.cs index da8239f737330..b59ae54c15c2f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSku.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSku.Serialization.cs @@ -116,28 +116,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToString()}'"); + builder.AppendLine($"'{Name.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Tier.Value.ToSerialString()}'"); + builder.AppendLine($"'{Tier.Value.ToSerialString()}'"); } } @@ -145,12 +145,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -171,13 +174,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuCapability.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuCapability.Serialization.cs index 06740d7f102db..8fe13624093db 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuCapability.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuCapability.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuInformation.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuInformation.Serialization.cs index fafdc910ad49c..81c4d1cd81224 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuInformation.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuInformation.Serialization.cs @@ -176,7 +176,7 @@ internal static StorageSkuInformation DeserializeStorageSkuInformation(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageSkuCapability.DeserializeStorageSkuCapability(item, options)); + array.Add(StorageSkuCapability.DeserializeStorageSkuCapability(item)); } capabilities = array; continue; @@ -190,7 +190,7 @@ internal static StorageSkuInformation DeserializeStorageSkuInformation(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageSkuRestriction.DeserializeStorageSkuRestriction(item, options)); + array.Add(StorageSkuRestriction.DeserializeStorageSkuRestriction(item)); } restrictions = array; continue; @@ -218,49 +218,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Name.ToString()}'"); + builder.AppendLine($"'{Name.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Tier.Value.ToSerialString()}'"); + builder.AppendLine($"'{Tier.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceType}'''"); } else { - builder.AppendLine($" '{ResourceType}'"); + builder.AppendLine($"'{ResourceType}'"); } } } @@ -268,14 +268,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.Value.ToString()}'"); + builder.AppendLine($"'{Kind.Value.ToString()}'"); } } @@ -284,14 +284,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Locations.Any() || hasPropertyOverride) { - builder.Append(" locations:"); + builder.Append(" locations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Locations) { if (item == null) @@ -319,17 +319,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Capabilities.Any() || hasPropertyOverride) { - builder.Append(" capabilities:"); + builder.Append(" capabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Capabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " capabilities: "); } builder.AppendLine(" ]"); } @@ -341,17 +341,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Restrictions.Any() || hasPropertyOverride) { - builder.Append(" restrictions:"); + builder.Append(" restrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Restrictions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " restrictions: "); } builder.AppendLine(" ]"); } @@ -362,12 +362,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -388,13 +391,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuListResult.Serialization.cs index d8650a58d8228..c94b9c4a1de9d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static StorageSkuListResult DeserializeStorageSkuListResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageSkuInformation.DeserializeStorageSkuInformation(item, options)); + array.Add(StorageSkuInformation.DeserializeStorageSkuInformation(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuRestriction.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuRestriction.Serialization.cs index 8119ff76bdd3d..0897e0c6be4dd 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuRestriction.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSkuRestriction.Serialization.cs @@ -147,14 +147,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Values.Any() || hasPropertyOverride) { - builder.Append(" values:"); + builder.Append(" values: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Values) { if (item == null) @@ -180,14 +180,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonCode), out propertyOverride); if (Optional.IsDefined(ReasonCode) || hasPropertyOverride) { - builder.Append(" reasonCode:"); + builder.Append(" reasonCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReasonCode.Value.ToString()}'"); + builder.AppendLine($"'{ReasonCode.Value.ToString()}'"); } } @@ -195,12 +195,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -221,13 +224,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSshPublicKey.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSshPublicKey.Serialization.cs index 8d23aac1a6505..0afd203a8c003 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSshPublicKey.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageSshPublicKey.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Key.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Key}'''"); } else { - builder.AppendLine($" '{Key}'"); + builder.AppendLine($"'{Key}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableAccessPolicy.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableAccessPolicy.Serialization.cs index e3f21f320f42e..90e3eca498c1d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableAccessPolicy.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableAccessPolicy.Serialization.cs @@ -131,51 +131,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expiryTime:"); + builder.Append(" expiryTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Permission), out propertyOverride); if (Optional.IsDefined(Permission) || hasPropertyOverride) { - builder.Append(" permission:"); + builder.Append(" permission: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Permission.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Permission}'''"); } else { - builder.AppendLine($" '{Permission}'"); + builder.AppendLine($"'{Permission}'"); } } } @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableSignedIdentifier.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableSignedIdentifier.Serialization.cs index 6a05115aa1856..7afc3e30bb862 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableSignedIdentifier.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageTableSignedIdentifier.Serialization.cs @@ -90,7 +90,7 @@ internal static StorageTableSignedIdentifier DeserializeStorageTableSignedIdenti { continue; } - accessPolicy = StorageTableAccessPolicy.DeserializeStorageTableAccessPolicy(property.Value, options); + accessPolicy = StorageTableAccessPolicy.DeserializeStorageTableAccessPolicy(property.Value); continue; } if (options.Format != "W") @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -138,14 +138,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessPolicy), out propertyOverride); if (Optional.IsDefined(AccessPolicy) || hasPropertyOverride) { - builder.Append(" accessPolicy:"); + builder.Append(" accessPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AccessPolicy, options, 2, false); + AppendChildObject(builder, AccessPolicy, options, 2, false, " accessPolicy: "); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsage.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsage.Serialization.cs index db5549dc606b5..59da355dbe200 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsage.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsage.Serialization.cs @@ -127,7 +127,7 @@ internal static StorageUsage DeserializeStorageUsage(JsonElement element, ModelR { continue; } - name = StorageUsageName.DeserializeStorageUsageName(property.Value, options); + name = StorageUsageName.DeserializeStorageUsageName(property.Value); continue; } if (options.Format != "W") @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Name, options, 2, false); + AppendChildObject(builder, Name, options, 2, false, " name: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Unit.Value.ToSerialString()}'"); + builder.AppendLine($"'{Unit.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentValue.Value}"); + builder.AppendLine($"{CurrentValue.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Limit.Value}"); + builder.AppendLine($"{Limit.Value}"); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsageName.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsageName.Serialization.cs index 0a839bfcf53c4..d86875011f708 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsageName.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/StorageUsageName.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalizedValue), out propertyOverride); if (Optional.IsDefined(LocalizedValue) || hasPropertyOverride) { - builder.Append(" localizedValue:"); + builder.Append(" localizedValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalizedValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalizedValue}'''"); } else { - builder.AppendLine($" '{LocalizedValue}'"); + builder.AppendLine($"'{LocalizedValue}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UpdateHistoryEntry.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UpdateHistoryEntry.Serialization.cs index be64571bde3f5..37fbf943d0037 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UpdateHistoryEntry.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UpdateHistoryEntry.Serialization.cs @@ -205,64 +205,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdateType), out propertyOverride); if (Optional.IsDefined(UpdateType) || hasPropertyOverride) { - builder.Append(" update:"); + builder.Append(" update: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UpdateType.Value.ToString()}'"); + builder.AppendLine($"'{UpdateType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutabilityPeriodSinceCreationInDays), out propertyOverride); if (Optional.IsDefined(ImmutabilityPeriodSinceCreationInDays) || hasPropertyOverride) { - builder.Append(" immutabilityPeriodSinceCreationInDays:"); + builder.Append(" immutabilityPeriodSinceCreationInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ImmutabilityPeriodSinceCreationInDays.Value}"); + builder.AppendLine($"{ImmutabilityPeriodSinceCreationInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectIdentifier), out propertyOverride); if (Optional.IsDefined(ObjectIdentifier) || hasPropertyOverride) { - builder.Append(" objectIdentifier:"); + builder.Append(" objectIdentifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ObjectIdentifier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ObjectIdentifier}'''"); } else { - builder.AppendLine($" '{ObjectIdentifier}'"); + builder.AppendLine($"'{ObjectIdentifier}'"); } } } @@ -270,35 +270,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); if (Optional.IsDefined(TenantId) || hasPropertyOverride) { - builder.Append(" tenantId:"); + builder.Append(" tenantId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TenantId.Value.ToString()}'"); + builder.AppendLine($"'{TenantId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Upn), out propertyOverride); if (Optional.IsDefined(Upn) || hasPropertyOverride) { - builder.Append(" upn:"); + builder.Append(" upn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Upn.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Upn}'''"); } else { - builder.AppendLine($" '{Upn}'"); + builder.AppendLine($"'{Upn}'"); } } } @@ -306,30 +306,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWrites), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWrites) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWrites:"); + builder.Append(" allowProtectedAppendWrites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWrites.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowProtectedAppendWritesAll), out propertyOverride); if (Optional.IsDefined(AllowProtectedAppendWritesAll) || hasPropertyOverride) { - builder.Append(" allowProtectedAppendWritesAll:"); + builder.Append(" allowProtectedAppendWritesAll: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowProtectedAppendWritesAll.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -337,12 +337,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -363,13 +366,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UsageListResult.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UsageListResult.Serialization.cs index 6e443361ca990..5d91fcc1cf3d2 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UsageListResult.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/Models/UsageListResult.Serialization.cs @@ -91,7 +91,7 @@ internal static UsageListResult DeserializeUsageListResult(JsonElement element, List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(StorageUsage.DeserializeStorageUsage(item, options)); + array.Add(StorageUsage.DeserializeStorageUsage(item)); } value = array; continue; @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs index 33852c86a89d6..76fb6effb7784 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs @@ -201,7 +201,7 @@ internal static ObjectReplicationPolicyData DeserializeObjectReplicationPolicyDa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(ObjectReplicationPolicyRule.DeserializeObjectReplicationPolicyRule(item, options)); + array.Add(ObjectReplicationPolicyRule.DeserializeObjectReplicationPolicyRule(item)); } rules = array; continue; @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -254,28 +254,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyId), out propertyOverride); if (Optional.IsDefined(PolicyId) || hasPropertyOverride) { - builder.Append(" policyId:"); + builder.Append(" policyId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PolicyId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PolicyId}'''"); } else { - builder.AppendLine($" '{PolicyId}'"); + builder.AppendLine($"'{PolicyId}'"); } } } @@ -306,36 +306,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledOn), out propertyOverride); if (Optional.IsDefined(EnabledOn) || hasPropertyOverride) { - builder.Append(" enabledTime:"); + builder.Append(" enabledTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EnabledOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceAccount), out propertyOverride); if (Optional.IsDefined(SourceAccount) || hasPropertyOverride) { - builder.Append(" sourceAccount:"); + builder.Append(" sourceAccount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceAccount.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceAccount}'''"); } else { - builder.AppendLine($" '{SourceAccount}'"); + builder.AppendLine($"'{SourceAccount}'"); } } } @@ -343,21 +343,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DestinationAccount), out propertyOverride); if (Optional.IsDefined(DestinationAccount) || hasPropertyOverride) { - builder.Append(" destinationAccount:"); + builder.Append(" destinationAccount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DestinationAccount.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DestinationAccount}'''"); } else { - builder.AppendLine($" '{DestinationAccount}'"); + builder.AppendLine($"'{DestinationAccount}'"); } } } @@ -367,17 +367,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Rules.Any() || hasPropertyOverride) { - builder.Append(" rules:"); + builder.Append(" rules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Rules) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " rules: "); } builder.AppendLine(" ]"); } @@ -389,12 +389,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -415,13 +418,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/QueueServiceData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/QueueServiceData.Serialization.cs index 61eaa9fe8a434..4310fb2565eee 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/QueueServiceData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/QueueServiceData.Serialization.cs @@ -144,7 +144,7 @@ internal static QueueServiceData DeserializeQueueServiceData(JsonElement element { continue; } - cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value, options); + cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value); continue; } } @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 4, false); + AppendChildObject(builder, Cors, options, 4, false, " cors: "); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs index dfb459cdee8c4..1bab4445b53dc 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs @@ -380,7 +380,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - sku = StorageSku.DeserializeStorageSku(property.Value, options); + sku = StorageSku.DeserializeStorageSku(property.Value); continue; } if (property.NameEquals("kind"u8)) @@ -478,7 +478,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - primaryEndpoints = StorageAccountEndpoints.DeserializeStorageAccountEndpoints(property0.Value, options); + primaryEndpoints = StorageAccountEndpoints.DeserializeStorageAccountEndpoints(property0.Value); continue; } if (property0.NameEquals("primaryLocation"u8)) @@ -541,7 +541,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value, options); + customDomain = StorageCustomDomain.DeserializeStorageCustomDomain(property0.Value); continue; } if (property0.NameEquals("sasPolicy"u8)) @@ -550,7 +550,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value, options); + sasPolicy = StorageAccountSasPolicy.DeserializeStorageAccountSasPolicy(property0.Value); continue; } if (property0.NameEquals("keyPolicy"u8)) @@ -559,7 +559,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value, options); + keyPolicy = StorageAccountKeyPolicy.DeserializeStorageAccountKeyPolicy(property0.Value); continue; } if (property0.NameEquals("keyCreationTime"u8)) @@ -568,7 +568,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - keyCreationTime = StorageAccountKeyCreationTime.DeserializeStorageAccountKeyCreationTime(property0.Value, options); + keyCreationTime = StorageAccountKeyCreationTime.DeserializeStorageAccountKeyCreationTime(property0.Value); continue; } if (property0.NameEquals("secondaryEndpoints"u8)) @@ -577,7 +577,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - secondaryEndpoints = StorageAccountEndpoints.DeserializeStorageAccountEndpoints(property0.Value, options); + secondaryEndpoints = StorageAccountEndpoints.DeserializeStorageAccountEndpoints(property0.Value); continue; } if (property0.NameEquals("encryption"u8)) @@ -586,7 +586,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value, options); + encryption = StorageAccountEncryption.DeserializeStorageAccountEncryption(property0.Value); continue; } if (property0.NameEquals("accessTier"u8)) @@ -604,7 +604,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value, options); + azureFilesIdentityBasedAuthentication = FilesIdentityBasedAuthentication.DeserializeFilesIdentityBasedAuthentication(property0.Value); continue; } if (property0.NameEquals("supportsHttpsTrafficOnly"u8)) @@ -622,7 +622,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value, options); + networkAcls = StorageAccountNetworkRuleSet.DeserializeStorageAccountNetworkRuleSet(property0.Value); continue; } if (property0.NameEquals("isSftpEnabled"u8)) @@ -658,7 +658,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - geoReplicationStats = GeoReplicationStatistics.DeserializeGeoReplicationStatistics(property0.Value, options); + geoReplicationStats = GeoReplicationStatistics.DeserializeGeoReplicationStatistics(property0.Value); continue; } if (property0.NameEquals("failoverInProgress"u8)) @@ -688,7 +688,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(StoragePrivateEndpointConnectionData.DeserializeStoragePrivateEndpointConnectionData(item, options)); + array.Add(StoragePrivateEndpointConnectionData.DeserializeStoragePrivateEndpointConnectionData(item)); } privateEndpointConnections = array; continue; @@ -699,7 +699,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value, options); + routingPreference = StorageRoutingPreference.DeserializeStorageRoutingPreference(property0.Value); continue; } if (property0.NameEquals("blobRestoreStatus"u8)) @@ -708,7 +708,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - blobRestoreStatus = BlobRestoreStatus.DeserializeBlobRestoreStatus(property0.Value, options); + blobRestoreStatus = BlobRestoreStatus.DeserializeBlobRestoreStatus(property0.Value); continue; } if (property0.NameEquals("allowBlobPublicAccess"u8)) @@ -780,7 +780,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value, options); + immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value); continue; } if (property0.NameEquals("allowedCopyScope"u8)) @@ -798,7 +798,7 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - storageAccountSkuConversionStatus = StorageAccountSkuConversionStatus.DeserializeStorageAccountSkuConversionStatus(property0.Value, options); + storageAccountSkuConversionStatus = StorageAccountSkuConversionStatus.DeserializeStorageAccountSkuConversionStatus(property0.Value); continue; } if (property0.NameEquals("dnsEndpointType"u8)) @@ -836,21 +836,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -858,14 +858,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -874,17 +874,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -892,12 +892,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -908,84 +908,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.Value.ToString()}'"); + builder.AppendLine($"'{Kind.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -994,343 +994,343 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryEndpoints), out propertyOverride); if (Optional.IsDefined(PrimaryEndpoints) || hasPropertyOverride) { - builder.Append(" primaryEndpoints:"); + builder.Append(" primaryEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrimaryEndpoints, options, 4, false); + AppendChildObject(builder, PrimaryEndpoints, options, 4, false, " primaryEndpoints: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryLocation), out propertyOverride); if (Optional.IsDefined(PrimaryLocation) || hasPropertyOverride) { - builder.Append(" primaryLocation:"); + builder.Append(" primaryLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrimaryLocation.Value.ToString()}'"); + builder.AppendLine($"'{PrimaryLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusOfPrimary), out propertyOverride); if (Optional.IsDefined(StatusOfPrimary) || hasPropertyOverride) { - builder.Append(" statusOfPrimary:"); + builder.Append(" statusOfPrimary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StatusOfPrimary.Value.ToSerialString()}'"); + builder.AppendLine($"'{StatusOfPrimary.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastGeoFailoverOn), out propertyOverride); if (Optional.IsDefined(LastGeoFailoverOn) || hasPropertyOverride) { - builder.Append(" lastGeoFailoverTime:"); + builder.Append(" lastGeoFailoverTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastGeoFailoverOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondaryLocation), out propertyOverride); if (Optional.IsDefined(SecondaryLocation) || hasPropertyOverride) { - builder.Append(" secondaryLocation:"); + builder.Append(" secondaryLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SecondaryLocation.Value.ToString()}'"); + builder.AppendLine($"'{SecondaryLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusOfSecondary), out propertyOverride); if (Optional.IsDefined(StatusOfSecondary) || hasPropertyOverride) { - builder.Append(" statusOfSecondary:"); + builder.Append(" statusOfSecondary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StatusOfSecondary.Value.ToSerialString()}'"); + builder.AppendLine($"'{StatusOfSecondary.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomain), out propertyOverride); if (Optional.IsDefined(CustomDomain) || hasPropertyOverride) { - builder.Append(" customDomain:"); + builder.Append(" customDomain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CustomDomain, options, 4, false); + AppendChildObject(builder, CustomDomain, options, 4, false, " customDomain: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasPolicy), out propertyOverride); if (Optional.IsDefined(SasPolicy) || hasPropertyOverride) { - builder.Append(" sasPolicy:"); + builder.Append(" sasPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SasPolicy, options, 4, false); + AppendChildObject(builder, SasPolicy, options, 4, false, " sasPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyPolicy), out propertyOverride); if (Optional.IsDefined(KeyPolicy) || hasPropertyOverride) { - builder.Append(" keyPolicy:"); + builder.Append(" keyPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyPolicy, options, 4, false); + AppendChildObject(builder, KeyPolicy, options, 4, false, " keyPolicy: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyCreationTime), out propertyOverride); if (Optional.IsDefined(KeyCreationTime) || hasPropertyOverride) { - builder.Append(" keyCreationTime:"); + builder.Append(" keyCreationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KeyCreationTime, options, 4, false); + AppendChildObject(builder, KeyCreationTime, options, 4, false, " keyCreationTime: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondaryEndpoints), out propertyOverride); if (Optional.IsDefined(SecondaryEndpoints) || hasPropertyOverride) { - builder.Append(" secondaryEndpoints:"); + builder.Append(" secondaryEndpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SecondaryEndpoints, options, 4, false); + AppendChildObject(builder, SecondaryEndpoints, options, 4, false, " secondaryEndpoints: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Encryption), out propertyOverride); if (Optional.IsDefined(Encryption) || hasPropertyOverride) { - builder.Append(" encryption:"); + builder.Append(" encryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Encryption, options, 4, false); + AppendChildObject(builder, Encryption, options, 4, false, " encryption: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessTier), out propertyOverride); if (Optional.IsDefined(AccessTier) || hasPropertyOverride) { - builder.Append(" accessTier:"); + builder.Append(" accessTier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AccessTier.Value.ToSerialString()}'"); + builder.AppendLine($"'{AccessTier.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureFilesIdentityBasedAuthentication), out propertyOverride); if (Optional.IsDefined(AzureFilesIdentityBasedAuthentication) || hasPropertyOverride) { - builder.Append(" azureFilesIdentityBasedAuthentication:"); + builder.Append(" azureFilesIdentityBasedAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureFilesIdentityBasedAuthentication, options, 4, false); + AppendChildObject(builder, AzureFilesIdentityBasedAuthentication, options, 4, false, " azureFilesIdentityBasedAuthentication: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnableHttpsTrafficOnly), out propertyOverride); if (Optional.IsDefined(EnableHttpsTrafficOnly) || hasPropertyOverride) { - builder.Append(" supportsHttpsTrafficOnly:"); + builder.Append(" supportsHttpsTrafficOnly: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = EnableHttpsTrafficOnly.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkRuleSet), out propertyOverride); if (Optional.IsDefined(NetworkRuleSet) || hasPropertyOverride) { - builder.Append(" networkAcls:"); + builder.Append(" networkAcls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, NetworkRuleSet, options, 4, false); + AppendChildObject(builder, NetworkRuleSet, options, 4, false, " networkAcls: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSftpEnabled), out propertyOverride); if (Optional.IsDefined(IsSftpEnabled) || hasPropertyOverride) { - builder.Append(" isSftpEnabled:"); + builder.Append(" isSftpEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSftpEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocalUserEnabled), out propertyOverride); if (Optional.IsDefined(IsLocalUserEnabled) || hasPropertyOverride) { - builder.Append(" isLocalUserEnabled:"); + builder.Append(" isLocalUserEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLocalUserEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHnsEnabled), out propertyOverride); if (Optional.IsDefined(IsHnsEnabled) || hasPropertyOverride) { - builder.Append(" isHnsEnabled:"); + builder.Append(" isHnsEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHnsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoReplicationStats), out propertyOverride); if (Optional.IsDefined(GeoReplicationStats) || hasPropertyOverride) { - builder.Append(" geoReplicationStats:"); + builder.Append(" geoReplicationStats: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GeoReplicationStats, options, 4, false); + AppendChildObject(builder, GeoReplicationStats, options, 4, false, " geoReplicationStats: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsFailoverInProgress), out propertyOverride); if (Optional.IsDefined(IsFailoverInProgress) || hasPropertyOverride) { - builder.Append(" failoverInProgress:"); + builder.Append(" failoverInProgress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsFailoverInProgress.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LargeFileSharesState), out propertyOverride); if (Optional.IsDefined(LargeFileSharesState) || hasPropertyOverride) { - builder.Append(" largeFileSharesState:"); + builder.Append(" largeFileSharesState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LargeFileSharesState.Value.ToString()}'"); + builder.AppendLine($"'{LargeFileSharesState.Value.ToString()}'"); } } @@ -1339,17 +1339,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -1359,187 +1359,187 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoutingPreference), out propertyOverride); if (Optional.IsDefined(RoutingPreference) || hasPropertyOverride) { - builder.Append(" routingPreference:"); + builder.Append(" routingPreference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RoutingPreference, options, 4, false); + AppendChildObject(builder, RoutingPreference, options, 4, false, " routingPreference: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobRestoreStatus), out propertyOverride); if (Optional.IsDefined(BlobRestoreStatus) || hasPropertyOverride) { - builder.Append(" blobRestoreStatus:"); + builder.Append(" blobRestoreStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BlobRestoreStatus, options, 4, false); + AppendChildObject(builder, BlobRestoreStatus, options, 4, false, " blobRestoreStatus: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowBlobPublicAccess), out propertyOverride); if (Optional.IsDefined(AllowBlobPublicAccess) || hasPropertyOverride) { - builder.Append(" allowBlobPublicAccess:"); + builder.Append(" allowBlobPublicAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowBlobPublicAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumTlsVersion), out propertyOverride); if (Optional.IsDefined(MinimumTlsVersion) || hasPropertyOverride) { - builder.Append(" minimumTlsVersion:"); + builder.Append(" minimumTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinimumTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{MinimumTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowSharedKeyAccess), out propertyOverride); if (Optional.IsDefined(AllowSharedKeyAccess) || hasPropertyOverride) { - builder.Append(" allowSharedKeyAccess:"); + builder.Append(" allowSharedKeyAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowSharedKeyAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNfsV3Enabled), out propertyOverride); if (Optional.IsDefined(IsNfsV3Enabled) || hasPropertyOverride) { - builder.Append(" isNfsV3Enabled:"); + builder.Append(" isNfsV3Enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsNfsV3Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowCrossTenantReplication), out propertyOverride); if (Optional.IsDefined(AllowCrossTenantReplication) || hasPropertyOverride) { - builder.Append(" allowCrossTenantReplication:"); + builder.Append(" allowCrossTenantReplication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowCrossTenantReplication.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefaultToOAuthAuthentication), out propertyOverride); if (Optional.IsDefined(IsDefaultToOAuthAuthentication) || hasPropertyOverride) { - builder.Append(" defaultToOAuthAuthentication:"); + builder.Append(" defaultToOAuthAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefaultToOAuthAuthentication.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicNetworkAccess.Value.ToString()}'"); + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmutableStorageWithVersioning), out propertyOverride); if (Optional.IsDefined(ImmutableStorageWithVersioning) || hasPropertyOverride) { - builder.Append(" immutableStorageWithVersioning:"); + builder.Append(" immutableStorageWithVersioning: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ImmutableStorageWithVersioning, options, 4, false); + AppendChildObject(builder, ImmutableStorageWithVersioning, options, 4, false, " immutableStorageWithVersioning: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedCopyScope), out propertyOverride); if (Optional.IsDefined(AllowedCopyScope) || hasPropertyOverride) { - builder.Append(" allowedCopyScope:"); + builder.Append(" allowedCopyScope: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AllowedCopyScope.Value.ToString()}'"); + builder.AppendLine($"'{AllowedCopyScope.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountSkuConversionStatus), out propertyOverride); if (Optional.IsDefined(StorageAccountSkuConversionStatus) || hasPropertyOverride) { - builder.Append(" storageAccountSkuConversionStatus:"); + builder.Append(" storageAccountSkuConversionStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StorageAccountSkuConversionStatus, options, 4, false); + AppendChildObject(builder, StorageAccountSkuConversionStatus, options, 4, false, " storageAccountSkuConversionStatus: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsEndpointType), out propertyOverride); if (Optional.IsDefined(DnsEndpointType) || hasPropertyOverride) { - builder.Append(" dnsEndpointType:"); + builder.Append(" dnsEndpointType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DnsEndpointType.Value.ToString()}'"); + builder.AppendLine($"'{DnsEndpointType.Value.ToString()}'"); } } @@ -1548,12 +1548,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1574,13 +1577,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountLocalUserData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountLocalUserData.Serialization.cs index 33f6194848002..a9805e850454b 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountLocalUserData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountLocalUserData.Serialization.cs @@ -194,7 +194,7 @@ internal static StorageAccountLocalUserData DeserializeStorageAccountLocalUserDa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(StoragePermissionScope.DeserializeStoragePermissionScope(item, options)); + array.Add(StoragePermissionScope.DeserializeStoragePermissionScope(item)); } permissionScopes = array; continue; @@ -213,7 +213,7 @@ internal static StorageAccountLocalUserData DeserializeStorageAccountLocalUserDa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(StorageSshPublicKey.DeserializeStorageSshPublicKey(item, options)); + array.Add(StorageSshPublicKey.DeserializeStorageSshPublicKey(item)); } sshAuthorizedKeys = array; continue; @@ -276,21 +276,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -298,28 +298,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -330,17 +330,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PermissionScopes.Any() || hasPropertyOverride) { - builder.Append(" permissionScopes:"); + builder.Append(" permissionScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PermissionScopes) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " permissionScopes: "); } builder.AppendLine(" ]"); } @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HomeDirectory), out propertyOverride); if (Optional.IsDefined(HomeDirectory) || hasPropertyOverride) { - builder.Append(" homeDirectory:"); + builder.Append(" homeDirectory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HomeDirectory.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HomeDirectory}'''"); } else { - builder.AppendLine($" '{HomeDirectory}'"); + builder.AppendLine($"'{HomeDirectory}'"); } } } @@ -374,17 +374,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SshAuthorizedKeys.Any() || hasPropertyOverride) { - builder.Append(" sshAuthorizedKeys:"); + builder.Append(" sshAuthorizedKeys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SshAuthorizedKeys) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " sshAuthorizedKeys: "); } builder.AppendLine(" ]"); } @@ -394,21 +394,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); if (Optional.IsDefined(Sid) || hasPropertyOverride) { - builder.Append(" sid:"); + builder.Append(" sid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Sid.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Sid}'''"); } else { - builder.AppendLine($" '{Sid}'"); + builder.AppendLine($"'{Sid}'"); } } } @@ -416,45 +416,45 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasSharedKey), out propertyOverride); if (Optional.IsDefined(HasSharedKey) || hasPropertyOverride) { - builder.Append(" hasSharedKey:"); + builder.Append(" hasSharedKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasSharedKey.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasSshKey), out propertyOverride); if (Optional.IsDefined(HasSshKey) || hasPropertyOverride) { - builder.Append(" hasSshKey:"); + builder.Append(" hasSshKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasSshKey.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasSshPassword), out propertyOverride); if (Optional.IsDefined(HasSshPassword) || hasPropertyOverride) { - builder.Append(" hasSshPassword:"); + builder.Append(" hasSshPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasSshPassword.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -463,12 +463,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -489,13 +492,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountManagementPolicyData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountManagementPolicyData.Serialization.cs index 16418f0c988d2..a5be225ae761f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountManagementPolicyData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageAccountManagementPolicyData.Serialization.cs @@ -159,7 +159,7 @@ internal static StorageAccountManagementPolicyData DeserializeStorageAccountMana { continue; } - policy = ManagementPolicySchema.DeserializeManagementPolicySchema(property0.Value, options); + policy = ManagementPolicySchema.DeserializeManagementPolicySchema(property0.Value); continue; } } @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,28 +210,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -240,29 +240,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTime:"); + builder.Append(" lastModifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Policy), out propertyOverride); if (Optional.IsDefined(Policy) || hasPropertyOverride) { - builder.Append(" policy:"); + builder.Append(" policy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Policy, options, 4, false); + AppendChildObject(builder, Policy, options, 4, false, " policy: "); } } @@ -271,12 +271,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -297,13 +300,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StoragePrivateEndpointConnectionData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StoragePrivateEndpointConnectionData.Serialization.cs index 49e8e9352b73d..7dda9de10363f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StoragePrivateEndpointConnectionData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StoragePrivateEndpointConnectionData.Serialization.cs @@ -166,7 +166,7 @@ internal static StoragePrivateEndpointConnectionData DeserializeStoragePrivateEn { continue; } - privateLinkServiceConnectionState = StoragePrivateLinkServiceConnectionState.DeserializeStoragePrivateLinkServiceConnectionState(property0.Value, options); + privateLinkServiceConnectionState = StoragePrivateLinkServiceConnectionState.DeserializeStoragePrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState"u8)) @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -226,28 +226,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -256,42 +256,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ConnectionState, options, 4, false); + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); } } @@ -300,12 +300,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -326,13 +329,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageQueueData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageQueueData.Serialization.cs index 5700c634f0e44..a3c14309867a3 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageQueueData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/StorageQueueData.Serialization.cs @@ -199,21 +199,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -221,28 +221,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,17 +253,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metadata.Any() || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Metadata) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -271,12 +271,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -287,14 +287,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApproximateMessageCount), out propertyOverride); if (Optional.IsDefined(ApproximateMessageCount) || hasPropertyOverride) { - builder.Append(" approximateMessageCount:"); + builder.Append(" approximateMessageCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ApproximateMessageCount.Value}"); + builder.AppendLine($"{ApproximateMessageCount.Value}"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableData.Serialization.cs index 0a74ea63172e1..d5aab0b18a612 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableData.Serialization.cs @@ -164,7 +164,7 @@ internal static TableData DeserializeTableData(JsonElement element, ModelReaderW List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(StorageTableSignedIdentifier.DeserializeStorageTableSignedIdentifier(item, options)); + array.Add(StorageTableSignedIdentifier.DeserializeStorageTableSignedIdentifier(item)); } signedIdentifiers = array; continue; @@ -195,21 +195,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -217,28 +217,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -247,21 +247,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); if (Optional.IsDefined(TableName) || hasPropertyOverride) { - builder.Append(" tableName:"); + builder.Append(" tableName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TableName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TableName}'''"); } else { - builder.AppendLine($" '{TableName}'"); + builder.AppendLine($"'{TableName}'"); } } } @@ -271,17 +271,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SignedIdentifiers.Any() || hasPropertyOverride) { - builder.Append(" signedIdentifiers:"); + builder.Append(" signedIdentifiers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SignedIdentifiers) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " signedIdentifiers: "); } builder.AppendLine(" ]"); } @@ -293,12 +293,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -319,13 +322,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableServiceData.Serialization.cs b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableServiceData.Serialization.cs index ca2b6ae7a3b33..40f4f30a95ffc 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableServiceData.Serialization.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/src/Generated/TableServiceData.Serialization.cs @@ -144,7 +144,7 @@ internal static TableServiceData DeserializeTableServiceData(JsonElement element { continue; } - cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value, options); + cors = StorageCorsRules.DeserializeStorageCorsRules(property0.Value); continue; } } @@ -173,21 +173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -195,28 +195,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -225,14 +225,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 4, false); + AppendChildObject(builder, Cors, options, 4, false, " cors: "); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ApiKeyVaultReferenceData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ApiKeyVaultReferenceData.Serialization.cs index bcf3f472bbfee..ffec87dbb261d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ApiKeyVaultReferenceData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ApiKeyVaultReferenceData.Serialization.cs @@ -280,21 +280,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -302,21 +302,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -324,28 +324,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -354,21 +354,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reference), out propertyOverride); if (Optional.IsDefined(Reference) || hasPropertyOverride) { - builder.Append(" reference:"); + builder.Append(" reference: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reference.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reference}'''"); } else { - builder.AppendLine($" '{Reference}'"); + builder.AppendLine($"'{Reference}'"); } } } @@ -376,35 +376,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VaultName), out propertyOverride); if (Optional.IsDefined(VaultName) || hasPropertyOverride) { - builder.Append(" vaultName:"); + builder.Append(" vaultName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VaultName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VaultName}'''"); } else { - builder.AppendLine($" '{VaultName}'"); + builder.AppendLine($"'{VaultName}'"); } } } @@ -412,21 +412,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretName), out propertyOverride); if (Optional.IsDefined(SecretName) || hasPropertyOverride) { - builder.Append(" secretName:"); + builder.Append(" secretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecretName}'''"); } else { - builder.AppendLine($" '{SecretName}'"); + builder.AppendLine($"'{SecretName}'"); } } } @@ -434,21 +434,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretVersion), out propertyOverride); if (Optional.IsDefined(SecretVersion) || hasPropertyOverride) { - builder.Append(" secretVersion:"); + builder.Append(" secretVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecretVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecretVersion}'''"); } else { - builder.AppendLine($" '{SecretVersion}'"); + builder.AppendLine($"'{SecretVersion}'"); } } } @@ -456,35 +456,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identityType:"); + builder.Append(" identityType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 4, false); + AppendChildObject(builder, Identity, options, 4, false, " identityType: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); if (Optional.IsDefined(Details) || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Details.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Details}'''"); } else { - builder.AppendLine($" '{Details}'"); + builder.AppendLine($"'{Details}'"); } } } @@ -492,35 +492,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Source.Value.ToString()}'"); + builder.AppendLine($"'{Source.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActiveVersion), out propertyOverride); if (Optional.IsDefined(ActiveVersion) || hasPropertyOverride) { - builder.Append(" activeVersion:"); + builder.Append(" activeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActiveVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActiveVersion}'''"); } else { - builder.AppendLine($" '{ActiveVersion}'"); + builder.AppendLine($"'{ActiveVersion}'"); } } } @@ -530,12 +530,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -556,13 +559,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppCertificateData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppCertificateData.Serialization.cs index 497a0e961ea18..3fc9f79f78c28 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppCertificateData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppCertificateData.Serialization.cs @@ -225,21 +225,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -247,14 +247,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -263,17 +263,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -281,12 +281,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -319,28 +319,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -349,21 +349,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); if (Optional.IsDefined(Password) || hasPropertyOverride) { - builder.Append(" password:"); + builder.Append(" password: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Password.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Password}'''"); } else { - builder.AppendLine($" '{Password}'"); + builder.AppendLine($"'{Password}'"); } } } @@ -371,21 +371,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FriendlyName), out propertyOverride); if (Optional.IsDefined(FriendlyName) || hasPropertyOverride) { - builder.Append(" friendlyName:"); + builder.Append(" friendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FriendlyName}'''"); } else { - builder.AppendLine($" '{FriendlyName}'"); + builder.AppendLine($"'{FriendlyName}'"); } } } @@ -393,21 +393,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectName), out propertyOverride); if (Optional.IsDefined(SubjectName) || hasPropertyOverride) { - builder.Append(" subjectName:"); + builder.Append(" subjectName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubjectName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubjectName}'''"); } else { - builder.AppendLine($" '{SubjectName}'"); + builder.AppendLine($"'{SubjectName}'"); } } } @@ -417,14 +417,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNames.Any() || hasPropertyOverride) { - builder.Append(" hostNames:"); + builder.Append(" hostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNames) { if (item == null) @@ -450,35 +450,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PfxBlob), out propertyOverride); if (Optional.IsDefined(PfxBlob) || hasPropertyOverride) { - builder.Append(" pfxBlob:"); + builder.Append(" pfxBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PfxBlob.ToString()}'"); + builder.AppendLine($"'{PfxBlob.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteName), out propertyOverride); if (Optional.IsDefined(SiteName) || hasPropertyOverride) { - builder.Append(" siteName:"); + builder.Append(" siteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteName}'''"); } else { - builder.AppendLine($" '{SiteName}'"); + builder.AppendLine($"'{SiteName}'"); } } } @@ -486,21 +486,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SelfLink), out propertyOverride); if (Optional.IsDefined(SelfLink) || hasPropertyOverride) { - builder.Append(" selfLink:"); + builder.Append(" selfLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SelfLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SelfLink}'''"); } else { - builder.AppendLine($" '{SelfLink}'"); + builder.AppendLine($"'{SelfLink}'"); } } } @@ -508,21 +508,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); if (Optional.IsDefined(Issuer) || hasPropertyOverride) { - builder.Append(" issuer:"); + builder.Append(" issuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Issuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Issuer}'''"); } else { - builder.AppendLine($" '{Issuer}'"); + builder.AppendLine($"'{Issuer}'"); } } } @@ -530,51 +530,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IssueOn), out propertyOverride); if (Optional.IsDefined(IssueOn) || hasPropertyOverride) { - builder.Append(" issueDate:"); + builder.Append(" issueDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(IssueOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationDate:"); + builder.Append(" expirationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -582,50 +582,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsValid), out propertyOverride); if (Optional.IsDefined(IsValid) || hasPropertyOverride) { - builder.Append(" valid:"); + builder.Append(" valid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsValid.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CerBlob), out propertyOverride); if (Optional.IsDefined(CerBlob) || hasPropertyOverride) { - builder.Append(" cerBlob:"); + builder.Append(" cerBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CerBlob.ToString()}'"); + builder.AppendLine($"'{CerBlob.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicKeyHash), out propertyOverride); if (Optional.IsDefined(PublicKeyHash) || hasPropertyOverride) { - builder.Append(" publicKeyHash:"); + builder.Append(" publicKeyHash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicKeyHash.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicKeyHash}'''"); } else { - builder.AppendLine($" '{PublicKeyHash}'"); + builder.AppendLine($"'{PublicKeyHash}'"); } } } @@ -633,49 +633,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultId), out propertyOverride); if (Optional.IsDefined(KeyVaultId) || hasPropertyOverride) { - builder.Append(" keyVaultId:"); + builder.Append(" keyVaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultId.ToString()}'"); + builder.AppendLine($"'{KeyVaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretName), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretName) || hasPropertyOverride) { - builder.Append(" keyVaultSecretName:"); + builder.Append(" keyVaultSecretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultSecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultSecretName}'''"); } else { - builder.AppendLine($" '{KeyVaultSecretName}'"); + builder.AppendLine($"'{KeyVaultSecretName}'"); } } } @@ -683,49 +683,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretStatus), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretStatus) || hasPropertyOverride) { - builder.Append(" keyVaultSecretStatus:"); + builder.Append(" keyVaultSecretStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultSecretStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{KeyVaultSecretStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerFarmId), out propertyOverride); if (Optional.IsDefined(ServerFarmId) || hasPropertyOverride) { - builder.Append(" serverFarmId:"); + builder.Append(" serverFarmId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerFarmId.ToString()}'"); + builder.AppendLine($"'{ServerFarmId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanonicalName), out propertyOverride); if (Optional.IsDefined(CanonicalName) || hasPropertyOverride) { - builder.Append(" canonicalName:"); + builder.Append(" canonicalName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CanonicalName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CanonicalName}'''"); } else { - builder.AppendLine($" '{CanonicalName}'"); + builder.AppendLine($"'{CanonicalName}'"); } } } @@ -733,21 +733,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainValidationMethod), out propertyOverride); if (Optional.IsDefined(DomainValidationMethod) || hasPropertyOverride) { - builder.Append(" domainValidationMethod:"); + builder.Append(" domainValidationMethod: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainValidationMethod.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainValidationMethod}'''"); } else { - builder.AppendLine($" '{DomainValidationMethod}'"); + builder.AppendLine($"'{DomainValidationMethod}'"); } } } @@ -757,12 +757,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -783,13 +786,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateData.Serialization.cs index 83d37e9456a1a..6057ccb46a951 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateData.Serialization.cs @@ -245,21 +245,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -267,14 +267,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -283,17 +283,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -301,12 +301,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -317,21 +317,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -339,28 +339,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -369,35 +369,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultId), out propertyOverride); if (Optional.IsDefined(KeyVaultId) || hasPropertyOverride) { - builder.Append(" keyVaultId:"); + builder.Append(" keyVaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultId.ToString()}'"); + builder.AppendLine($"'{KeyVaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretName), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretName) || hasPropertyOverride) { - builder.Append(" keyVaultSecretName:"); + builder.Append(" keyVaultSecretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultSecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultSecretName}'''"); } else { - builder.AppendLine($" '{KeyVaultSecretName}'"); + builder.AppendLine($"'{KeyVaultSecretName}'"); } } } @@ -405,14 +405,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } @@ -421,12 +421,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -447,13 +450,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateOrderData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateOrderData.Serialization.cs index 85f003182a9c8..6993855775c89 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateOrderData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceCertificateOrderData.Serialization.cs @@ -509,21 +509,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -531,14 +531,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -547,17 +547,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -565,12 +565,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -581,21 +581,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -603,28 +603,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -635,18 +635,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Certificates.Any() || hasPropertyOverride) { - builder.Append(" certificates:"); + builder.Append(" certificates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Certificates) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " certificates: "); } builder.AppendLine(" }"); } @@ -656,21 +656,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DistinguishedName), out propertyOverride); if (Optional.IsDefined(DistinguishedName) || hasPropertyOverride) { - builder.Append(" distinguishedName:"); + builder.Append(" distinguishedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DistinguishedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DistinguishedName}'''"); } else { - builder.AppendLine($" '{DistinguishedName}'"); + builder.AppendLine($"'{DistinguishedName}'"); } } } @@ -678,21 +678,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainVerificationToken), out propertyOverride); if (Optional.IsDefined(DomainVerificationToken) || hasPropertyOverride) { - builder.Append(" domainVerificationToken:"); + builder.Append(" domainVerificationToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainVerificationToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainVerificationToken}'''"); } else { - builder.AppendLine($" '{DomainVerificationToken}'"); + builder.AppendLine($"'{DomainVerificationToken}'"); } } } @@ -700,120 +700,120 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidityInYears), out propertyOverride); if (Optional.IsDefined(ValidityInYears) || hasPropertyOverride) { - builder.Append(" validityInYears:"); + builder.Append(" validityInYears: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ValidityInYears.Value}"); + builder.AppendLine($"{ValidityInYears.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); if (Optional.IsDefined(KeySize) || hasPropertyOverride) { - builder.Append(" keySize:"); + builder.Append(" keySize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {KeySize.Value}"); + builder.AppendLine($"{KeySize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProductType), out propertyOverride); if (Optional.IsDefined(ProductType) || hasPropertyOverride) { - builder.Append(" productType:"); + builder.Append(" productType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProductType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProductType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRenew), out propertyOverride); if (Optional.IsDefined(IsAutoRenew) || hasPropertyOverride) { - builder.Append(" autoRenew:"); + builder.Append(" autoRenew: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRenew.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SignedCertificate), out propertyOverride); if (Optional.IsDefined(SignedCertificate) || hasPropertyOverride) { - builder.Append(" signedCertificate:"); + builder.Append(" signedCertificate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SignedCertificate, options, 4, false); + AppendChildObject(builder, SignedCertificate, options, 4, false, " signedCertificate: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Csr), out propertyOverride); if (Optional.IsDefined(Csr) || hasPropertyOverride) { - builder.Append(" csr:"); + builder.Append(" csr: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Csr.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Csr}'''"); } else { - builder.AppendLine($" '{Csr}'"); + builder.AppendLine($"'{Csr}'"); } } } @@ -821,49 +821,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Intermediate), out propertyOverride); if (Optional.IsDefined(Intermediate) || hasPropertyOverride) { - builder.Append(" intermediate:"); + builder.Append(" intermediate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Intermediate, options, 4, false); + AppendChildObject(builder, Intermediate, options, 4, false, " intermediate: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Root), out propertyOverride); if (Optional.IsDefined(Root) || hasPropertyOverride) { - builder.Append(" root:"); + builder.Append(" root: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Root, options, 4, false); + AppendChildObject(builder, Root, options, 4, false, " root: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SerialNumber), out propertyOverride); if (Optional.IsDefined(SerialNumber) || hasPropertyOverride) { - builder.Append(" serialNumber:"); + builder.Append(" serialNumber: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SerialNumber.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SerialNumber}'''"); } else { - builder.AppendLine($" '{SerialNumber}'"); + builder.AppendLine($"'{SerialNumber}'"); } } } @@ -871,45 +871,45 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastCertificateIssuedOn), out propertyOverride); if (Optional.IsDefined(LastCertificateIssuedOn) || hasPropertyOverride) { - builder.Append(" lastCertificateIssuanceTime:"); + builder.Append(" lastCertificateIssuanceTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastCertificateIssuedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrivateKeyExternal), out propertyOverride); if (Optional.IsDefined(IsPrivateKeyExternal) || hasPropertyOverride) { - builder.Append(" isPrivateKeyExternal:"); + builder.Append(" isPrivateKeyExternal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrivateKeyExternal.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -918,14 +918,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppServiceCertificateNotRenewableReasons.Any() || hasPropertyOverride) { - builder.Append(" appServiceCertificateNotRenewableReasons:"); + builder.Append(" appServiceCertificateNotRenewableReasons: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AppServiceCertificateNotRenewableReasons) { builder.AppendLine($" '{item.ToString()}'"); @@ -938,29 +938,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextAutoRenewTimeStamp), out propertyOverride); if (Optional.IsDefined(NextAutoRenewTimeStamp) || hasPropertyOverride) { - builder.Append(" nextAutoRenewalTimeStamp:"); + builder.Append(" nextAutoRenewalTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextAutoRenewTimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Contact), out propertyOverride); if (Optional.IsDefined(Contact) || hasPropertyOverride) { - builder.Append(" contact:"); + builder.Append(" contact: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Contact, options, 4, false); + AppendChildObject(builder, Contact, options, 4, false, " contact: "); } } @@ -969,12 +969,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -995,13 +998,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDetectorData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDetectorData.Serialization.cs index 0aa72ccfd8704..44fa1433484c2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDetectorData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDetectorData.Serialization.cs @@ -265,21 +265,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -287,21 +287,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -309,28 +309,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -339,14 +339,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Metadata, options, 4, false); + AppendChildObject(builder, Metadata, options, 4, false, " metadata: "); } } @@ -355,17 +355,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Dataset.Any() || hasPropertyOverride) { - builder.Append(" dataset:"); + builder.Append(" dataset: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Dataset) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " dataset: "); } builder.AppendLine(" ]"); } @@ -375,14 +375,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Status, options, 4, false); + AppendChildObject(builder, Status, options, 4, false, " status: "); } } @@ -391,17 +391,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DataProvidersMetadata.Any() || hasPropertyOverride) { - builder.Append(" dataProvidersMetadata:"); + builder.Append(" dataProvidersMetadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DataProvidersMetadata) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " dataProvidersMetadata: "); } builder.AppendLine(" ]"); } @@ -411,14 +411,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuggestedUtterances), out propertyOverride); if (Optional.IsDefined(SuggestedUtterances) || hasPropertyOverride) { - builder.Append(" suggestedUtterances:"); + builder.Append(" suggestedUtterances: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SuggestedUtterances, options, 4, false); + AppendChildObject(builder, SuggestedUtterances, options, 4, false, " suggestedUtterances: "); } } @@ -427,12 +427,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -453,13 +456,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDomainData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDomainData.Serialization.cs index b62751fc2b88e..e4319b195ccc3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDomainData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceDomainData.Serialization.cs @@ -526,21 +526,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -548,14 +548,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -564,17 +564,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -582,12 +582,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -598,21 +598,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -620,28 +620,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -650,84 +650,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactAdmin), out propertyOverride); if (Optional.IsDefined(ContactAdmin) || hasPropertyOverride) { - builder.Append(" contactAdmin:"); + builder.Append(" contactAdmin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactAdmin, options, 4, false); + AppendChildObject(builder, ContactAdmin, options, 4, false, " contactAdmin: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactBilling), out propertyOverride); if (Optional.IsDefined(ContactBilling) || hasPropertyOverride) { - builder.Append(" contactBilling:"); + builder.Append(" contactBilling: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactBilling, options, 4, false); + AppendChildObject(builder, ContactBilling, options, 4, false, " contactBilling: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactRegistrant), out propertyOverride); if (Optional.IsDefined(ContactRegistrant) || hasPropertyOverride) { - builder.Append(" contactRegistrant:"); + builder.Append(" contactRegistrant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactRegistrant, options, 4, false); + AppendChildObject(builder, ContactRegistrant, options, 4, false, " contactRegistrant: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactTech), out propertyOverride); if (Optional.IsDefined(ContactTech) || hasPropertyOverride) { - builder.Append(" contactTech:"); + builder.Append(" contactTech: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactTech, options, 4, false); + AppendChildObject(builder, ContactTech, options, 4, false, " contactTech: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistrationStatus), out propertyOverride); if (Optional.IsDefined(RegistrationStatus) || hasPropertyOverride) { - builder.Append(" registrationStatus:"); + builder.Append(" registrationStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RegistrationStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{RegistrationStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } @@ -736,14 +736,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NameServers.Any() || hasPropertyOverride) { - builder.Append(" nameServers:"); + builder.Append(" nameServers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NameServers) { if (item == null) @@ -769,90 +769,90 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDomainPrivacyEnabled), out propertyOverride); if (Optional.IsDefined(IsDomainPrivacyEnabled) || hasPropertyOverride) { - builder.Append(" privacy:"); + builder.Append(" privacy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDomainPrivacyEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdTime:"); + builder.Append(" createdTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRenewedOn), out propertyOverride); if (Optional.IsDefined(LastRenewedOn) || hasPropertyOverride) { - builder.Append(" lastRenewedTime:"); + builder.Append(" lastRenewedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastRenewedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRenew), out propertyOverride); if (Optional.IsDefined(IsAutoRenew) || hasPropertyOverride) { - builder.Append(" autoRenew:"); + builder.Append(" autoRenew: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRenew.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDnsRecordManagementReady), out propertyOverride); if (Optional.IsDefined(IsDnsRecordManagementReady) || hasPropertyOverride) { - builder.Append(" readyForDnsRecordManagement:"); + builder.Append(" readyForDnsRecordManagement: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDnsRecordManagementReady.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -861,17 +861,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagedHostNames.Any() || hasPropertyOverride) { - builder.Append(" managedHostNames:"); + builder.Append(" managedHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagedHostNames) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " managedHostNames: "); } builder.AppendLine(" ]"); } @@ -881,14 +881,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Consent), out propertyOverride); if (Optional.IsDefined(Consent) || hasPropertyOverride) { - builder.Append(" consent:"); + builder.Append(" consent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Consent, options, 4, false); + AppendChildObject(builder, Consent, options, 4, false, " consent: "); } } @@ -897,14 +897,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DomainNotRenewableReasons.Any() || hasPropertyOverride) { - builder.Append(" domainNotRenewableReasons:"); + builder.Append(" domainNotRenewableReasons: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DomainNotRenewableReasons) { builder.AppendLine($" '{item.ToString()}'"); @@ -917,35 +917,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsType), out propertyOverride); if (Optional.IsDefined(DnsType) || hasPropertyOverride) { - builder.Append(" dnsType:"); + builder.Append(" dnsType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DnsType.Value.ToSerialString()}'"); + builder.AppendLine($"'{DnsType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsZoneId), out propertyOverride); if (Optional.IsDefined(DnsZoneId) || hasPropertyOverride) { - builder.Append(" dnsZoneId:"); + builder.Append(" dnsZoneId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsZoneId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsZoneId}'''"); } else { - builder.AppendLine($" '{DnsZoneId}'"); + builder.AppendLine($"'{DnsZoneId}'"); } } } @@ -953,35 +953,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetDnsType), out propertyOverride); if (Optional.IsDefined(TargetDnsType) || hasPropertyOverride) { - builder.Append(" targetDnsType:"); + builder.Append(" targetDnsType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetDnsType.Value.ToSerialString()}'"); + builder.AppendLine($"'{TargetDnsType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthCode), out propertyOverride); if (Optional.IsDefined(AuthCode) || hasPropertyOverride) { - builder.Append(" authCode:"); + builder.Append(" authCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthCode}'''"); } else { - builder.AppendLine($" '{AuthCode}'"); + builder.AppendLine($"'{AuthCode}'"); } } } @@ -991,12 +991,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1017,13 +1020,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceEnvironmentData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceEnvironmentData.Serialization.cs index 65fd6104bceb9..8f6d20a75d149 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceEnvironmentData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceEnvironmentData.Serialization.cs @@ -456,21 +456,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -478,14 +478,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -494,17 +494,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -512,12 +512,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -528,21 +528,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -550,28 +550,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -580,77 +580,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetwork), out propertyOverride); if (Optional.IsDefined(VirtualNetwork) || hasPropertyOverride) { - builder.Append(" virtualNetwork:"); + builder.Append(" virtualNetwork: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, VirtualNetwork, options, 4, false); + AppendChildObject(builder, VirtualNetwork, options, 4, false, " virtualNetwork: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalLoadBalancingMode), out propertyOverride); if (Optional.IsDefined(InternalLoadBalancingMode) || hasPropertyOverride) { - builder.Append(" internalLoadBalancingMode:"); + builder.Append(" internalLoadBalancingMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InternalLoadBalancingMode.Value.ToString()}'"); + builder.AppendLine($"'{InternalLoadBalancingMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiSize), out propertyOverride); if (Optional.IsDefined(MultiSize) || hasPropertyOverride) { - builder.Append(" multiSize:"); + builder.Append(" multiSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MultiSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MultiSize}'''"); } else { - builder.AppendLine($" '{MultiSize}'"); + builder.AppendLine($"'{MultiSize}'"); } } } @@ -658,49 +658,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiRoleCount), out propertyOverride); if (Optional.IsDefined(MultiRoleCount) || hasPropertyOverride) { - builder.Append(" multiRoleCount:"); + builder.Append(" multiRoleCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MultiRoleCount.Value}"); + builder.AppendLine($"{MultiRoleCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPSslAddressCount), out propertyOverride); if (Optional.IsDefined(IPSslAddressCount) || hasPropertyOverride) { - builder.Append(" ipsslAddressCount:"); + builder.Append(" ipsslAddressCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {IPSslAddressCount.Value}"); + builder.AppendLine($"{IPSslAddressCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsSuffix), out propertyOverride); if (Optional.IsDefined(DnsSuffix) || hasPropertyOverride) { - builder.Append(" dnsSuffix:"); + builder.Append(" dnsSuffix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsSuffix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsSuffix}'''"); } else { - builder.AppendLine($" '{DnsSuffix}'"); + builder.AppendLine($"'{DnsSuffix}'"); } } } @@ -708,43 +708,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNumberOfMachines), out propertyOverride); if (Optional.IsDefined(MaximumNumberOfMachines) || hasPropertyOverride) { - builder.Append(" maximumNumberOfMachines:"); + builder.Append(" maximumNumberOfMachines: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumNumberOfMachines.Value}"); + builder.AppendLine($"{MaximumNumberOfMachines.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrontEndScaleFactor), out propertyOverride); if (Optional.IsDefined(FrontEndScaleFactor) || hasPropertyOverride) { - builder.Append(" frontEndScaleFactor:"); + builder.Append(" frontEndScaleFactor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FrontEndScaleFactor.Value}"); + builder.AppendLine($"{FrontEndScaleFactor.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSuspended), out propertyOverride); if (Optional.IsDefined(IsSuspended) || hasPropertyOverride) { - builder.Append(" suspended:"); + builder.Append(" suspended: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSuspended.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -753,17 +753,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ClusterSettings.Any() || hasPropertyOverride) { - builder.Append(" clusterSettings:"); + builder.Append(" clusterSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ClusterSettings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " clusterSettings: "); } builder.AppendLine(" ]"); } @@ -775,14 +775,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserWhitelistedIPRanges.Any() || hasPropertyOverride) { - builder.Append(" userWhitelistedIpRanges:"); + builder.Append(" userWhitelistedIpRanges: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserWhitelistedIPRanges) { if (item == null) @@ -808,44 +808,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLinuxWorkers), out propertyOverride); if (Optional.IsDefined(HasLinuxWorkers) || hasPropertyOverride) { - builder.Append(" hasLinuxWorkers:"); + builder.Append(" hasLinuxWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLinuxWorkers.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DedicatedHostCount), out propertyOverride); if (Optional.IsDefined(DedicatedHostCount) || hasPropertyOverride) { - builder.Append(" dedicatedHostCount:"); + builder.Append(" dedicatedHostCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DedicatedHostCount.Value}"); + builder.AppendLine($"{DedicatedHostCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -854,12 +854,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -880,13 +883,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceIdentifierData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceIdentifierData.Serialization.cs index 3cedee701dbe4..f2965becba8a5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceIdentifierData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceIdentifierData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServicePlanData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServicePlanData.Serialization.cs index b5bdbe9228d3e..04a0fa4727935 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServicePlanData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServicePlanData.Serialization.cs @@ -581,21 +581,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -603,14 +603,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -619,17 +619,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -637,12 +637,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -653,49 +653,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -703,28 +703,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -733,21 +733,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerTierName), out propertyOverride); if (Optional.IsDefined(WorkerTierName) || hasPropertyOverride) { - builder.Append(" workerTierName:"); + builder.Append(" workerTierName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WorkerTierName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WorkerTierName}'''"); } else { - builder.AppendLine($" '{WorkerTierName}'"); + builder.AppendLine($"'{WorkerTierName}'"); } } } @@ -755,35 +755,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subscription), out propertyOverride); if (Optional.IsDefined(Subscription) || hasPropertyOverride) { - builder.Append(" subscription:"); + builder.Append(" subscription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subscription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subscription}'''"); } else { - builder.AppendLine($" '{Subscription}'"); + builder.AppendLine($"'{Subscription}'"); } } } @@ -791,49 +791,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNumberOfWorkers), out propertyOverride); if (Optional.IsDefined(MaximumNumberOfWorkers) || hasPropertyOverride) { - builder.Append(" maximumNumberOfWorkers:"); + builder.Append(" maximumNumberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumNumberOfWorkers.Value}"); + builder.AppendLine($"{MaximumNumberOfWorkers.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoRegion), out propertyOverride); if (Optional.IsDefined(GeoRegion) || hasPropertyOverride) { - builder.Append(" geoRegion:"); + builder.Append(" geoRegion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GeoRegion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GeoRegion}'''"); } else { - builder.AppendLine($" '{GeoRegion}'"); + builder.AppendLine($"'{GeoRegion}'"); } } } @@ -841,124 +841,124 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPerSiteScaling), out propertyOverride); if (Optional.IsDefined(IsPerSiteScaling) || hasPropertyOverride) { - builder.Append(" perSiteScaling:"); + builder.Append(" perSiteScaling: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPerSiteScaling.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsElasticScaleEnabled), out propertyOverride); if (Optional.IsDefined(IsElasticScaleEnabled) || hasPropertyOverride) { - builder.Append(" elasticScaleEnabled:"); + builder.Append(" elasticScaleEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsElasticScaleEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumElasticWorkerCount), out propertyOverride); if (Optional.IsDefined(MaximumElasticWorkerCount) || hasPropertyOverride) { - builder.Append(" maximumElasticWorkerCount:"); + builder.Append(" maximumElasticWorkerCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumElasticWorkerCount.Value}"); + builder.AppendLine($"{MaximumElasticWorkerCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfSites), out propertyOverride); if (Optional.IsDefined(NumberOfSites) || hasPropertyOverride) { - builder.Append(" numberOfSites:"); + builder.Append(" numberOfSites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfSites.Value}"); + builder.AppendLine($"{NumberOfSites.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSpot), out propertyOverride); if (Optional.IsDefined(IsSpot) || hasPropertyOverride) { - builder.Append(" isSpot:"); + builder.Append(" isSpot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSpot.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SpotExpireOn), out propertyOverride); if (Optional.IsDefined(SpotExpireOn) || hasPropertyOverride) { - builder.Append(" spotExpirationTime:"); + builder.Append(" spotExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SpotExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FreeOfferExpireOn), out propertyOverride); if (Optional.IsDefined(FreeOfferExpireOn) || hasPropertyOverride) { - builder.Append(" freeOfferExpirationTime:"); + builder.Append(" freeOfferExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(FreeOfferExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroup), out propertyOverride); if (Optional.IsDefined(ResourceGroup) || hasPropertyOverride) { - builder.Append(" resourceGroup:"); + builder.Append(" resourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroup}'''"); } else { - builder.AppendLine($" '{ResourceGroup}'"); + builder.AppendLine($"'{ResourceGroup}'"); } } } @@ -966,116 +966,116 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReserved), out propertyOverride); if (Optional.IsDefined(IsReserved) || hasPropertyOverride) { - builder.Append(" reserved:"); + builder.Append(" reserved: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReserved.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsXenon), out propertyOverride); if (Optional.IsDefined(IsXenon) || hasPropertyOverride) { - builder.Append(" isXenon:"); + builder.Append(" isXenon: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsXenon.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHyperV), out propertyOverride); if (Optional.IsDefined(IsHyperV) || hasPropertyOverride) { - builder.Append(" hyperV:"); + builder.Append(" hyperV: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHyperV.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetWorkerCount), out propertyOverride); if (Optional.IsDefined(TargetWorkerCount) || hasPropertyOverride) { - builder.Append(" targetWorkerCount:"); + builder.Append(" targetWorkerCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TargetWorkerCount.Value}"); + builder.AppendLine($"{TargetWorkerCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetWorkerSizeId), out propertyOverride); if (Optional.IsDefined(TargetWorkerSizeId) || hasPropertyOverride) { - builder.Append(" targetWorkerSizeId:"); + builder.Append(" targetWorkerSizeId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TargetWorkerSizeId.Value}"); + builder.AppendLine($"{TargetWorkerSizeId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KubeEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(KubeEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" kubeEnvironmentProfile:"); + builder.Append(" kubeEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KubeEnvironmentProfile, options, 4, false); + AppendChildObject(builder, KubeEnvironmentProfile, options, 4, false, " kubeEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -1084,12 +1084,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1110,13 +1113,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceSourceControlData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceSourceControlData.Serialization.cs index 243e7d3fbd1ee..baf72032a2f51 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceSourceControlData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceSourceControlData.Serialization.cs @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -260,28 +260,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -290,21 +290,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Token), out propertyOverride); if (Optional.IsDefined(Token) || hasPropertyOverride) { - builder.Append(" token:"); + builder.Append(" token: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Token.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Token}'''"); } else { - builder.AppendLine($" '{Token}'"); + builder.AppendLine($"'{Token}'"); } } } @@ -312,21 +312,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenSecret), out propertyOverride); if (Optional.IsDefined(TokenSecret) || hasPropertyOverride) { - builder.Append(" tokenSecret:"); + builder.Append(" tokenSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TokenSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TokenSecret}'''"); } else { - builder.AppendLine($" '{TokenSecret}'"); + builder.AppendLine($"'{TokenSecret}'"); } } } @@ -334,21 +334,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RefreshToken), out propertyOverride); if (Optional.IsDefined(RefreshToken) || hasPropertyOverride) { - builder.Append(" refreshToken:"); + builder.Append(" refreshToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RefreshToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RefreshToken}'''"); } else { - builder.AppendLine($" '{RefreshToken}'"); + builder.AppendLine($"'{RefreshToken}'"); } } } @@ -356,15 +356,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -373,12 +373,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -399,13 +402,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkData.Serialization.cs index 74a4d72d29fb7..14b5e00bb10e1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkData.Serialization.cs @@ -273,21 +273,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -295,21 +295,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -317,28 +317,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -347,35 +347,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetResourceId), out propertyOverride); if (Optional.IsDefined(VnetResourceId) || hasPropertyOverride) { - builder.Append(" vnetResourceId:"); + builder.Append(" vnetResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VnetResourceId.ToString()}'"); + builder.AppendLine($"'{VnetResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertThumbprintString), out propertyOverride); if (Optional.IsDefined(CertThumbprintString) || hasPropertyOverride) { - builder.Append(" certThumbprint:"); + builder.Append(" certThumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertThumbprintString}'''"); } else { - builder.AppendLine($" '{CertThumbprintString}'"); + builder.AppendLine($"'{CertThumbprintString}'"); } } } @@ -383,21 +383,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertBlob), out propertyOverride); if (Optional.IsDefined(CertBlob) || hasPropertyOverride) { - builder.Append(" certBlob:"); + builder.Append(" certBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertBlob.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertBlob}'''"); } else { - builder.AppendLine($" '{CertBlob}'"); + builder.AppendLine($"'{CertBlob}'"); } } } @@ -407,17 +407,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Routes.Any() || hasPropertyOverride) { - builder.Append(" routes:"); + builder.Append(" routes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Routes) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " routes: "); } builder.AppendLine(" ]"); } @@ -427,36 +427,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsResyncRequired), out propertyOverride); if (Optional.IsDefined(IsResyncRequired) || hasPropertyOverride) { - builder.Append(" resyncRequired:"); + builder.Append(" resyncRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsResyncRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsServers), out propertyOverride); if (Optional.IsDefined(DnsServers) || hasPropertyOverride) { - builder.Append(" dnsServers:"); + builder.Append(" dnsServers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsServers.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsServers}'''"); } else { - builder.AppendLine($" '{DnsServers}'"); + builder.AppendLine($"'{DnsServers}'"); } } } @@ -464,15 +464,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSwift), out propertyOverride); if (Optional.IsDefined(IsSwift) || hasPropertyOverride) { - builder.Append(" isSwift:"); + builder.Append(" isSwift: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSwift.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -481,12 +481,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -507,13 +510,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkGatewayData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkGatewayData.Serialization.cs index 721267342d3f4..ce36362f418bf 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkGatewayData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceVirtualNetworkGatewayData.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetName), out propertyOverride); if (Optional.IsDefined(VnetName) || hasPropertyOverride) { - builder.Append(" vnetName:"); + builder.Append(" vnetName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetName}'''"); } else { - builder.AppendLine($" '{VnetName}'"); + builder.AppendLine($"'{VnetName}'"); } } } @@ -290,14 +290,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VpnPackageUri), out propertyOverride); if (Optional.IsDefined(VpnPackageUri) || hasPropertyOverride) { - builder.Append(" vpnPackageUri:"); + builder.Append(" vpnPackageUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VpnPackageUri.AbsoluteUri}'"); + builder.AppendLine($"'{VpnPackageUri.AbsoluteUri}'"); } } @@ -306,12 +306,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -332,13 +335,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceWorkerPoolData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceWorkerPoolData.Serialization.cs index e6e9bf331b755..0479e9f6f5b14 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceWorkerPoolData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AppServiceWorkerPoolData.Serialization.cs @@ -266,21 +266,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -288,35 +288,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -324,28 +324,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -354,49 +354,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerSizeId), out propertyOverride); if (Optional.IsDefined(WorkerSizeId) || hasPropertyOverride) { - builder.Append(" workerSizeId:"); + builder.Append(" workerSizeId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {WorkerSizeId.Value}"); + builder.AppendLine($"{WorkerSizeId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ComputeMode), out propertyOverride); if (Optional.IsDefined(ComputeMode) || hasPropertyOverride) { - builder.Append(" computeMode:"); + builder.Append(" computeMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ComputeMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ComputeMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerSize), out propertyOverride); if (Optional.IsDefined(WorkerSize) || hasPropertyOverride) { - builder.Append(" workerSize:"); + builder.Append(" workerSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WorkerSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WorkerSize}'''"); } else { - builder.AppendLine($" '{WorkerSize}'"); + builder.AppendLine($"'{WorkerSize}'"); } } } @@ -404,14 +404,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerCount), out propertyOverride); if (Optional.IsDefined(WorkerCount) || hasPropertyOverride) { - builder.Append(" workerCount:"); + builder.Append(" workerCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {WorkerCount.Value}"); + builder.AppendLine($"{WorkerCount.Value}"); } } @@ -420,14 +420,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (InstanceNames.Any() || hasPropertyOverride) { - builder.Append(" instanceNames:"); + builder.Append(" instanceNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in InstanceNames) { if (item == null) @@ -455,12 +455,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -481,13 +484,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AseV3NetworkingConfigurationData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AseV3NetworkingConfigurationData.Serialization.cs index f915be0a1dd77..5cdfe5ca8f40e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AseV3NetworkingConfigurationData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/AseV3NetworkingConfigurationData.Serialization.cs @@ -333,21 +333,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -355,21 +355,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -377,28 +377,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -409,14 +409,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (WindowsOutboundIPAddresses.Any() || hasPropertyOverride) { - builder.Append(" windowsOutboundIpAddresses:"); + builder.Append(" windowsOutboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in WindowsOutboundIPAddresses) { if (item == null) @@ -436,14 +436,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LinuxOutboundIPAddresses.Any() || hasPropertyOverride) { - builder.Append(" linuxOutboundIpAddresses:"); + builder.Append(" linuxOutboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LinuxOutboundIPAddresses) { if (item == null) @@ -463,14 +463,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExternalInboundIPAddresses.Any() || hasPropertyOverride) { - builder.Append(" externalInboundIpAddresses:"); + builder.Append(" externalInboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExternalInboundIPAddresses) { if (item == null) @@ -490,14 +490,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (InternalInboundIPAddresses.Any() || hasPropertyOverride) { - builder.Append(" internalInboundIpAddresses:"); + builder.Append(" internalInboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in InternalInboundIPAddresses) { if (item == null) @@ -515,15 +515,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowNewPrivateEndpointConnections), out propertyOverride); if (Optional.IsDefined(AllowNewPrivateEndpointConnections) || hasPropertyOverride) { - builder.Append(" allowNewPrivateEndpointConnections:"); + builder.Append(" allowNewPrivateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowNewPrivateEndpointConnections.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -532,12 +532,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -558,13 +561,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ContinuousWebJobData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ContinuousWebJobData.Serialization.cs index 697488ef4cb51..fccafb5ad57ce 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ContinuousWebJobData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ContinuousWebJobData.Serialization.cs @@ -338,21 +338,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -360,21 +360,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -382,28 +382,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -412,35 +412,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetailedStatus), out propertyOverride); if (Optional.IsDefined(DetailedStatus) || hasPropertyOverride) { - builder.Append(" detailed_status:"); + builder.Append(" detailed_status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DetailedStatus.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DetailedStatus}'''"); } else { - builder.AppendLine($" '{DetailedStatus}'"); + builder.AppendLine($"'{DetailedStatus}'"); } } } @@ -448,35 +448,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogUri), out propertyOverride); if (Optional.IsDefined(LogUri) || hasPropertyOverride) { - builder.Append(" log_url:"); + builder.Append(" log_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LogUri.AbsoluteUri}'"); + builder.AppendLine($"'{LogUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunCommand), out propertyOverride); if (Optional.IsDefined(RunCommand) || hasPropertyOverride) { - builder.Append(" run_command:"); + builder.Append(" run_command: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RunCommand.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RunCommand}'''"); } else { - builder.AppendLine($" '{RunCommand}'"); + builder.AppendLine($"'{RunCommand}'"); } } } @@ -484,63 +484,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtraInfoUri), out propertyOverride); if (Optional.IsDefined(ExtraInfoUri) || hasPropertyOverride) { - builder.Append(" extra_info_url:"); + builder.Append(" extra_info_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExtraInfoUri.AbsoluteUri}'"); + builder.AppendLine($"'{ExtraInfoUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebJobType), out propertyOverride); if (Optional.IsDefined(WebJobType) || hasPropertyOverride) { - builder.Append(" web_job_type:"); + builder.Append(" web_job_type: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebJobType.Value.ToSerialString()}'"); + builder.AppendLine($"'{WebJobType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Error.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Error}'''"); } else { - builder.AppendLine($" '{Error}'"); + builder.AppendLine($"'{Error}'"); } } } @@ -548,15 +548,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUsingSdk), out propertyOverride); if (Optional.IsDefined(IsUsingSdk) || hasPropertyOverride) { - builder.Append(" using_sdk:"); + builder.Append(" using_sdk: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUsingSdk.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -565,23 +565,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Settings.Any() || hasPropertyOverride) { - builder.Append(" settings:"); + builder.Append(" settings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Settings) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -593,12 +593,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -619,13 +622,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/CsmPublishingCredentialsPoliciesEntityData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/CsmPublishingCredentialsPoliciesEntityData.Serialization.cs index a2c55bff3177a..22378f16992ad 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/CsmPublishingCredentialsPoliciesEntityData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/CsmPublishingCredentialsPoliciesEntityData.Serialization.cs @@ -183,21 +183,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -257,15 +257,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Allow), out propertyOverride); if (Optional.IsDefined(Allow) || hasPropertyOverride) { - builder.Append(" allow:"); + builder.Append(" allow: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Allow.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DeletedSiteData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DeletedSiteData.Serialization.cs index 986edc5553559..4322e1e5f4362 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DeletedSiteData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DeletedSiteData.Serialization.cs @@ -260,21 +260,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -282,21 +282,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -304,28 +304,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -334,35 +334,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedSiteId), out propertyOverride); if (Optional.IsDefined(DeletedSiteId) || hasPropertyOverride) { - builder.Append(" deletedSiteId:"); + builder.Append(" deletedSiteId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DeletedSiteId.Value}"); + builder.AppendLine($"{DeletedSiteId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedTimestamp), out propertyOverride); if (Optional.IsDefined(DeletedTimestamp) || hasPropertyOverride) { - builder.Append(" deletedTimestamp:"); + builder.Append(" deletedTimestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeletedTimestamp.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeletedTimestamp}'''"); } else { - builder.AppendLine($" '{DeletedTimestamp}'"); + builder.AppendLine($"'{DeletedTimestamp}'"); } } } @@ -370,21 +370,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subscription), out propertyOverride); if (Optional.IsDefined(Subscription) || hasPropertyOverride) { - builder.Append(" subscription:"); + builder.Append(" subscription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subscription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subscription}'''"); } else { - builder.AppendLine($" '{Subscription}'"); + builder.AppendLine($"'{Subscription}'"); } } } @@ -392,21 +392,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroup), out propertyOverride); if (Optional.IsDefined(ResourceGroup) || hasPropertyOverride) { - builder.Append(" resourceGroup:"); + builder.Append(" resourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroup}'''"); } else { - builder.AppendLine($" '{ResourceGroup}'"); + builder.AppendLine($"'{ResourceGroup}'"); } } } @@ -414,21 +414,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedSiteName), out propertyOverride); if (Optional.IsDefined(DeletedSiteName) || hasPropertyOverride) { - builder.Append(" deletedSiteName:"); + builder.Append(" deletedSiteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeletedSiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeletedSiteName}'''"); } else { - builder.AppendLine($" '{DeletedSiteName}'"); + builder.AppendLine($"'{DeletedSiteName}'"); } } } @@ -436,21 +436,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Slot), out propertyOverride); if (Optional.IsDefined(Slot) || hasPropertyOverride) { - builder.Append(" slot:"); + builder.Append(" slot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Slot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Slot}'''"); } else { - builder.AppendLine($" '{Slot}'"); + builder.AppendLine($"'{Slot}'"); } } } @@ -458,21 +458,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KindPropertiesKind), out propertyOverride); if (Optional.IsDefined(KindPropertiesKind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KindPropertiesKind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KindPropertiesKind}'''"); } else { - builder.AppendLine($" '{KindPropertiesKind}'"); + builder.AppendLine($"'{KindPropertiesKind}'"); } } } @@ -480,21 +480,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoRegionName), out propertyOverride); if (Optional.IsDefined(GeoRegionName) || hasPropertyOverride) { - builder.Append(" geoRegionName:"); + builder.Append(" geoRegionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GeoRegionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GeoRegionName}'''"); } else { - builder.AppendLine($" '{GeoRegionName}'"); + builder.AppendLine($"'{GeoRegionName}'"); } } } @@ -504,12 +504,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -530,13 +533,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DetectorDefinitionResourceData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DetectorDefinitionResourceData.Serialization.cs index dce8d2e9cadb8..179059a5a8c8e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DetectorDefinitionResourceData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DetectorDefinitionResourceData.Serialization.cs @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -264,28 +264,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -294,21 +294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -316,21 +316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -338,29 +338,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rank), out propertyOverride); if (Optional.IsDefined(Rank) || hasPropertyOverride) { - builder.Append(" rank:"); + builder.Append(" rank: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Rank.Value.ToString()}'"); + builder.AppendLine($"'{Rank.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" isEnabled:"); + builder.Append(" isEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -369,12 +369,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -395,13 +398,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DiagnosticCategoryData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DiagnosticCategoryData.Serialization.cs index ff209b549aa0a..2ab59d7befe28 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DiagnosticCategoryData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DiagnosticCategoryData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DomainOwnershipIdentifierData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DomainOwnershipIdentifierData.Serialization.cs index 546cfb0353f02..87f2822c29f34 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DomainOwnershipIdentifierData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/DomainOwnershipIdentifierData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OwnershipId), out propertyOverride); if (Optional.IsDefined(OwnershipId) || hasPropertyOverride) { - builder.Append(" ownershipId:"); + builder.Append(" ownershipId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OwnershipId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OwnershipId}'''"); } else { - builder.AppendLine($" '{OwnershipId}'"); + builder.AppendLine($"'{OwnershipId}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/FunctionEnvelopeData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/FunctionEnvelopeData.Serialization.cs index 278a65b497c97..653549225f5af 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/FunctionEnvelopeData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/FunctionEnvelopeData.Serialization.cs @@ -342,21 +342,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -364,21 +364,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -386,28 +386,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -416,21 +416,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAppId), out propertyOverride); if (Optional.IsDefined(FunctionAppId) || hasPropertyOverride) { - builder.Append(" function_app_id:"); + builder.Append(" function_app_id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FunctionAppId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FunctionAppId}'''"); } else { - builder.AppendLine($" '{FunctionAppId}'"); + builder.AppendLine($"'{FunctionAppId}'"); } } } @@ -438,21 +438,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScriptRootPathHref), out propertyOverride); if (Optional.IsDefined(ScriptRootPathHref) || hasPropertyOverride) { - builder.Append(" script_root_path_href:"); + builder.Append(" script_root_path_href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScriptRootPathHref.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScriptRootPathHref}'''"); } else { - builder.AppendLine($" '{ScriptRootPathHref}'"); + builder.AppendLine($"'{ScriptRootPathHref}'"); } } } @@ -460,21 +460,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScriptHref), out propertyOverride); if (Optional.IsDefined(ScriptHref) || hasPropertyOverride) { - builder.Append(" script_href:"); + builder.Append(" script_href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScriptHref.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScriptHref}'''"); } else { - builder.AppendLine($" '{ScriptHref}'"); + builder.AppendLine($"'{ScriptHref}'"); } } } @@ -482,21 +482,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConfigHref), out propertyOverride); if (Optional.IsDefined(ConfigHref) || hasPropertyOverride) { - builder.Append(" config_href:"); + builder.Append(" config_href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConfigHref.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConfigHref}'''"); } else { - builder.AppendLine($" '{ConfigHref}'"); + builder.AppendLine($"'{ConfigHref}'"); } } } @@ -504,21 +504,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TestDataHref), out propertyOverride); if (Optional.IsDefined(TestDataHref) || hasPropertyOverride) { - builder.Append(" test_data_href:"); + builder.Append(" test_data_href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TestDataHref.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TestDataHref}'''"); } else { - builder.AppendLine($" '{TestDataHref}'"); + builder.AppendLine($"'{TestDataHref}'"); } } } @@ -526,21 +526,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretsFileHref), out propertyOverride); if (Optional.IsDefined(SecretsFileHref) || hasPropertyOverride) { - builder.Append(" secrets_file_href:"); + builder.Append(" secrets_file_href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SecretsFileHref.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SecretsFileHref}'''"); } else { - builder.AppendLine($" '{SecretsFileHref}'"); + builder.AppendLine($"'{SecretsFileHref}'"); } } } @@ -548,21 +548,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Href), out propertyOverride); if (Optional.IsDefined(Href) || hasPropertyOverride) { - builder.Append(" href:"); + builder.Append(" href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Href.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Href}'''"); } else { - builder.AppendLine($" '{Href}'"); + builder.AppendLine($"'{Href}'"); } } } @@ -570,14 +570,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Config), out propertyOverride); if (Optional.IsDefined(Config) || hasPropertyOverride) { - builder.Append(" config:"); + builder.Append(" config: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Config.ToString()}'"); + builder.AppendLine($"'{Config.ToString()}'"); } } @@ -586,17 +586,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Files.Any() || hasPropertyOverride) { - builder.Append(" files:"); + builder.Append(" files: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Files) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -604,12 +604,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -620,21 +620,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TestData), out propertyOverride); if (Optional.IsDefined(TestData) || hasPropertyOverride) { - builder.Append(" test_data:"); + builder.Append(" test_data: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TestData.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TestData}'''"); } else { - builder.AppendLine($" '{TestData}'"); + builder.AppendLine($"'{TestData}'"); } } } @@ -642,21 +642,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InvokeUrlTemplate), out propertyOverride); if (Optional.IsDefined(InvokeUrlTemplate) || hasPropertyOverride) { - builder.Append(" invoke_url_template:"); + builder.Append(" invoke_url_template: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InvokeUrlTemplate.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InvokeUrlTemplate}'''"); } else { - builder.AppendLine($" '{InvokeUrlTemplate}'"); + builder.AppendLine($"'{InvokeUrlTemplate}'"); } } } @@ -664,21 +664,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Language), out propertyOverride); if (Optional.IsDefined(Language) || hasPropertyOverride) { - builder.Append(" language:"); + builder.Append(" language: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Language.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Language}'''"); } else { - builder.AppendLine($" '{Language}'"); + builder.AppendLine($"'{Language}'"); } } } @@ -686,15 +686,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDisabled), out propertyOverride); if (Optional.IsDefined(IsDisabled) || hasPropertyOverride) { - builder.Append(" isDisabled:"); + builder.Append(" isDisabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDisabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -703,12 +703,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -729,13 +732,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HostNameBindingData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HostNameBindingData.Serialization.cs index d675f3e83dd47..c4cb9700be6b6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HostNameBindingData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HostNameBindingData.Serialization.cs @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -306,21 +306,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -328,28 +328,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -358,21 +358,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteName), out propertyOverride); if (Optional.IsDefined(SiteName) || hasPropertyOverride) { - builder.Append(" siteName:"); + builder.Append(" siteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteName}'''"); } else { - builder.AppendLine($" '{SiteName}'"); + builder.AppendLine($"'{SiteName}'"); } } } @@ -380,21 +380,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainId), out propertyOverride); if (Optional.IsDefined(DomainId) || hasPropertyOverride) { - builder.Append(" domainId:"); + builder.Append(" domainId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainId}'''"); } else { - builder.AppendLine($" '{DomainId}'"); + builder.AppendLine($"'{DomainId}'"); } } } @@ -402,21 +402,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureResourceName), out propertyOverride); if (Optional.IsDefined(AzureResourceName) || hasPropertyOverride) { - builder.Append(" azureResourceName:"); + builder.Append(" azureResourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzureResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzureResourceName}'''"); } else { - builder.AppendLine($" '{AzureResourceName}'"); + builder.AppendLine($"'{AzureResourceName}'"); } } } @@ -424,77 +424,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureResourceType), out propertyOverride); if (Optional.IsDefined(AzureResourceType) || hasPropertyOverride) { - builder.Append(" azureResourceType:"); + builder.Append(" azureResourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AzureResourceType.Value.ToSerialString()}'"); + builder.AppendLine($"'{AzureResourceType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomHostNameDnsRecordType), out propertyOverride); if (Optional.IsDefined(CustomHostNameDnsRecordType) || hasPropertyOverride) { - builder.Append(" customHostNameDnsRecordType:"); + builder.Append(" customHostNameDnsRecordType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CustomHostNameDnsRecordType.Value.ToSerialString()}'"); + builder.AppendLine($"'{CustomHostNameDnsRecordType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostNameType), out propertyOverride); if (Optional.IsDefined(HostNameType) || hasPropertyOverride) { - builder.Append(" hostNameType:"); + builder.Append(" hostNameType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{HostNameType.Value.ToSerialString()}'"); + builder.AppendLine($"'{HostNameType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SslState), out propertyOverride); if (Optional.IsDefined(SslState) || hasPropertyOverride) { - builder.Append(" sslState:"); + builder.Append(" sslState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SslState.Value.ToSerialString()}'"); + builder.AppendLine($"'{SslState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -502,21 +502,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualIP), out propertyOverride); if (Optional.IsDefined(VirtualIP) || hasPropertyOverride) { - builder.Append(" virtualIP:"); + builder.Append(" virtualIP: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualIP.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualIP}'''"); } else { - builder.AppendLine($" '{VirtualIP}'"); + builder.AppendLine($"'{VirtualIP}'"); } } } @@ -526,12 +526,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -552,13 +555,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionData.Serialization.cs index bcbfc0b1b6f03..8d8b616afc56c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionData.Serialization.cs @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -308,28 +308,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -338,21 +338,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceBusNamespace), out propertyOverride); if (Optional.IsDefined(ServiceBusNamespace) || hasPropertyOverride) { - builder.Append(" serviceBusNamespace:"); + builder.Append(" serviceBusNamespace: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceBusNamespace.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceBusNamespace}'''"); } else { - builder.AppendLine($" '{ServiceBusNamespace}'"); + builder.AppendLine($"'{ServiceBusNamespace}'"); } } } @@ -360,21 +360,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RelayName), out propertyOverride); if (Optional.IsDefined(RelayName) || hasPropertyOverride) { - builder.Append(" relayName:"); + builder.Append(" relayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RelayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RelayName}'''"); } else { - builder.AppendLine($" '{RelayName}'"); + builder.AppendLine($"'{RelayName}'"); } } } @@ -382,35 +382,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RelayArmId), out propertyOverride); if (Optional.IsDefined(RelayArmId) || hasPropertyOverride) { - builder.Append(" relayArmUri:"); + builder.Append(" relayArmUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RelayArmId.ToString()}'"); + builder.AppendLine($"'{RelayArmId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Hostname), out propertyOverride); if (Optional.IsDefined(Hostname) || hasPropertyOverride) { - builder.Append(" hostname:"); + builder.Append(" hostname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Hostname.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Hostname}'''"); } else { - builder.AppendLine($" '{Hostname}'"); + builder.AppendLine($"'{Hostname}'"); } } } @@ -418,35 +418,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); if (Optional.IsDefined(Port) || hasPropertyOverride) { - builder.Append(" port:"); + builder.Append(" port: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Port.Value}"); + builder.AppendLine($"{Port.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendKeyName), out propertyOverride); if (Optional.IsDefined(SendKeyName) || hasPropertyOverride) { - builder.Append(" sendKeyName:"); + builder.Append(" sendKeyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SendKeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SendKeyName}'''"); } else { - builder.AppendLine($" '{SendKeyName}'"); + builder.AppendLine($"'{SendKeyName}'"); } } } @@ -454,21 +454,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendKeyValue), out propertyOverride); if (Optional.IsDefined(SendKeyValue) || hasPropertyOverride) { - builder.Append(" sendKeyValue:"); + builder.Append(" sendKeyValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SendKeyValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SendKeyValue}'''"); } else { - builder.AppendLine($" '{SendKeyValue}'"); + builder.AppendLine($"'{SendKeyValue}'"); } } } @@ -476,21 +476,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceBusSuffix), out propertyOverride); if (Optional.IsDefined(ServiceBusSuffix) || hasPropertyOverride) { - builder.Append(" serviceBusSuffix:"); + builder.Append(" serviceBusSuffix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceBusSuffix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceBusSuffix}'''"); } else { - builder.AppendLine($" '{ServiceBusSuffix}'"); + builder.AppendLine($"'{ServiceBusSuffix}'"); } } } @@ -500,12 +500,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -526,13 +529,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionLimitData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionLimitData.Serialization.cs index e70e4d92f22be..212d969bb7f17 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionLimitData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/HybridConnectionLimitData.Serialization.cs @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,28 +272,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Current), out propertyOverride); if (Optional.IsDefined(Current) || hasPropertyOverride) { - builder.Append(" current:"); + builder.Append(" current: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Current.Value}"); + builder.AppendLine($"{Current.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Maximum), out propertyOverride); if (Optional.IsDefined(Maximum) || hasPropertyOverride) { - builder.Append(" maximum:"); + builder.Append(" maximum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Maximum.Value}"); + builder.AppendLine($"{Maximum.Value}"); } } @@ -302,12 +302,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -328,13 +331,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/KubeEnvironmentData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/KubeEnvironmentData.Serialization.cs index 5dbece6100295..098fa3821b980 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/KubeEnvironmentData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/KubeEnvironmentData.Serialization.cs @@ -328,21 +328,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -350,14 +350,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -366,17 +366,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -384,12 +384,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -400,35 +400,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -436,28 +436,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -466,35 +466,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentErrors), out propertyOverride); if (Optional.IsDefined(DeploymentErrors) || hasPropertyOverride) { - builder.Append(" deploymentErrors:"); + builder.Append(" deploymentErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeploymentErrors.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeploymentErrors}'''"); } else { - builder.AppendLine($" '{DeploymentErrors}'"); + builder.AppendLine($"'{DeploymentErrors}'"); } } } @@ -502,36 +502,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInternalLoadBalancerEnabled), out propertyOverride); if (Optional.IsDefined(IsInternalLoadBalancerEnabled) || hasPropertyOverride) { - builder.Append(" internalLoadBalancerEnabled:"); + builder.Append(" internalLoadBalancerEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInternalLoadBalancerEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDomain), out propertyOverride); if (Optional.IsDefined(DefaultDomain) || hasPropertyOverride) { - builder.Append(" defaultDomain:"); + builder.Append(" defaultDomain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultDomain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultDomain}'''"); } else { - builder.AppendLine($" '{DefaultDomain}'"); + builder.AppendLine($"'{DefaultDomain}'"); } } } @@ -539,21 +539,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StaticIP), out propertyOverride); if (Optional.IsDefined(StaticIP) || hasPropertyOverride) { - builder.Append(" staticIp:"); + builder.Append(" staticIp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StaticIP.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StaticIP}'''"); } else { - builder.AppendLine($" '{StaticIP}'"); + builder.AppendLine($"'{StaticIP}'"); } } } @@ -561,42 +561,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArcConfiguration), out propertyOverride); if (Optional.IsDefined(ArcConfiguration) || hasPropertyOverride) { - builder.Append(" arcConfiguration:"); + builder.Append(" arcConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ArcConfiguration, options, 4, false); + AppendChildObject(builder, ArcConfiguration, options, 4, false, " arcConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppLogsConfiguration), out propertyOverride); if (Optional.IsDefined(AppLogsConfiguration) || hasPropertyOverride) { - builder.Append(" appLogsConfiguration:"); + builder.Append(" appLogsConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AppLogsConfiguration, options, 4, false); + AppendChildObject(builder, AppLogsConfiguration, options, 4, false, " appLogsConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AksResourceId), out propertyOverride); if (Optional.IsDefined(AksResourceId) || hasPropertyOverride) { - builder.Append(" aksResourceID:"); + builder.Append(" aksResourceID: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AksResourceId.ToString()}'"); + builder.AppendLine($"'{AksResourceId.ToString()}'"); } } @@ -605,12 +605,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -631,13 +634,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MSDeployStatusData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MSDeployStatusData.Serialization.cs index 14a6a6f2385a0..8dcac205b8b76 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MSDeployStatusData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MSDeployStatusData.Serialization.cs @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -284,28 +284,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -314,21 +314,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Deployer), out propertyOverride); if (Optional.IsDefined(Deployer) || hasPropertyOverride) { - builder.Append(" deployer:"); + builder.Append(" deployer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Deployer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Deployer}'''"); } else { - builder.AppendLine($" '{Deployer}'"); + builder.AppendLine($"'{Deployer}'"); } } } @@ -336,59 +336,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsComplete), out propertyOverride); if (Optional.IsDefined(IsComplete) || hasPropertyOverride) { - builder.Append(" complete:"); + builder.Append(" complete: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsComplete.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -397,12 +397,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -423,13 +426,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MigrateMySqlStatusData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MigrateMySqlStatusData.Serialization.cs index 4928e10e52fbd..f8b4e7e041ac8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MigrateMySqlStatusData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/MigrateMySqlStatusData.Serialization.cs @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -254,28 +254,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -284,35 +284,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MigrationOperationStatus), out propertyOverride); if (Optional.IsDefined(MigrationOperationStatus) || hasPropertyOverride) { - builder.Append(" migrationOperationStatus:"); + builder.Append(" migrationOperationStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MigrationOperationStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{MigrationOperationStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationId), out propertyOverride); if (Optional.IsDefined(OperationId) || hasPropertyOverride) { - builder.Append(" operationId:"); + builder.Append(" operationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationId}'''"); } else { - builder.AppendLine($" '{OperationId}'"); + builder.AppendLine($"'{OperationId}'"); } } } @@ -320,15 +320,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocalMySqlEnabled), out propertyOverride); if (Optional.IsDefined(IsLocalMySqlEnabled) || hasPropertyOverride) { - builder.Append(" localMySqlEnabled:"); + builder.Append(" localMySqlEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLocalMySqlEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -337,12 +337,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -363,13 +366,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AbnormalTimePeriod.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AbnormalTimePeriod.Serialization.cs index 1017a29497498..e361b56611bbb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AbnormalTimePeriod.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AbnormalTimePeriod.Serialization.cs @@ -174,30 +174,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -206,17 +206,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Events.Any() || hasPropertyOverride) { - builder.Append(" events:"); + builder.Append(" events: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Events) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " events: "); } builder.AppendLine(" ]"); } @@ -228,17 +228,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Solutions.Any() || hasPropertyOverride) { - builder.Append(" solutions:"); + builder.Append(" solutions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Solutions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " solutions: "); } builder.AppendLine(" ]"); } @@ -249,12 +249,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -275,13 +278,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs index 3b38a08c2a572..091bd38bcb477 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs @@ -121,14 +121,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedAudiences.Any() || hasPropertyOverride) { - builder.Append(" allowedAudiences:"); + builder.Append(" allowedAudiences: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedAudiences) { if (item == null) @@ -155,12 +155,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -181,13 +184,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AnalysisDetectorEvidences.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AnalysisDetectorEvidences.Serialization.cs index 54e0cdc470af4..de4f1466eff2e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AnalysisDetectorEvidences.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AnalysisDetectorEvidences.Serialization.cs @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Source.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Source}'''"); } else { - builder.AppendLine($" '{Source}'"); + builder.AppendLine($"'{Source}'"); } } } @@ -229,14 +229,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetectorDefinition), out propertyOverride); if (Optional.IsDefined(DetectorDefinition) || hasPropertyOverride) { - builder.Append(" detectorDefinition:"); + builder.Append(" detectorDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DetectorDefinition, options, 2, false); + AppendChildObject(builder, DetectorDefinition, options, 2, false, " detectorDefinition: "); } } @@ -245,17 +245,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metrics.Any() || hasPropertyOverride) { - builder.Append(" metrics:"); + builder.Append(" metrics: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Metrics) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " metrics: "); } builder.AppendLine(" ]"); } @@ -267,14 +267,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Data.Any() || hasPropertyOverride) { - builder.Append(" data:"); + builder.Append(" data: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Data) { if (item == null) @@ -282,10 +282,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { - AppendChildObject(builder, item0, options, 4, true); + AppendChildObject(builder, item0, options, 4, true, " data: "); } builder.AppendLine(" ]"); } @@ -297,14 +297,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetectorMetaData), out propertyOverride); if (Optional.IsDefined(DetectorMetaData) || hasPropertyOverride) { - builder.Append(" detectorMetaData:"); + builder.Append(" detectorMetaData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DetectorMetaData, options, 2, false); + AppendChildObject(builder, DetectorMetaData, options, 2, false, " detectorMetaData: "); } } @@ -312,12 +312,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -338,13 +341,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApiManagementConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApiManagementConfig.Serialization.cs index a7121a4cd25ba..596900d2ac40f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApiManagementConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApiManagementConfig.Serialization.cs @@ -116,21 +116,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -139,12 +139,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -165,13 +168,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificateListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificateListResult.Serialization.cs index d860ebceb0849..1b93b1cb8bceb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificateListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificateListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificatePatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificatePatch.Serialization.cs index 6d2112dc28708..7ee44e10f773a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificatePatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppCertificatePatch.Serialization.cs @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -255,28 +255,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -285,21 +285,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); if (Optional.IsDefined(Password) || hasPropertyOverride) { - builder.Append(" password:"); + builder.Append(" password: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Password.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Password}'''"); } else { - builder.AppendLine($" '{Password}'"); + builder.AppendLine($"'{Password}'"); } } } @@ -307,21 +307,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FriendlyName), out propertyOverride); if (Optional.IsDefined(FriendlyName) || hasPropertyOverride) { - builder.Append(" friendlyName:"); + builder.Append(" friendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FriendlyName}'''"); } else { - builder.AppendLine($" '{FriendlyName}'"); + builder.AppendLine($"'{FriendlyName}'"); } } } @@ -329,21 +329,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectName), out propertyOverride); if (Optional.IsDefined(SubjectName) || hasPropertyOverride) { - builder.Append(" subjectName:"); + builder.Append(" subjectName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubjectName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubjectName}'''"); } else { - builder.AppendLine($" '{SubjectName}'"); + builder.AppendLine($"'{SubjectName}'"); } } } @@ -353,14 +353,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNames.Any() || hasPropertyOverride) { - builder.Append(" hostNames:"); + builder.Append(" hostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNames) { if (item == null) @@ -386,35 +386,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PfxBlob), out propertyOverride); if (Optional.IsDefined(PfxBlob) || hasPropertyOverride) { - builder.Append(" pfxBlob:"); + builder.Append(" pfxBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PfxBlob.ToString()}'"); + builder.AppendLine($"'{PfxBlob.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteName), out propertyOverride); if (Optional.IsDefined(SiteName) || hasPropertyOverride) { - builder.Append(" siteName:"); + builder.Append(" siteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteName}'''"); } else { - builder.AppendLine($" '{SiteName}'"); + builder.AppendLine($"'{SiteName}'"); } } } @@ -422,21 +422,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SelfLink), out propertyOverride); if (Optional.IsDefined(SelfLink) || hasPropertyOverride) { - builder.Append(" selfLink:"); + builder.Append(" selfLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SelfLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SelfLink}'''"); } else { - builder.AppendLine($" '{SelfLink}'"); + builder.AppendLine($"'{SelfLink}'"); } } } @@ -444,21 +444,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); if (Optional.IsDefined(Issuer) || hasPropertyOverride) { - builder.Append(" issuer:"); + builder.Append(" issuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Issuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Issuer}'''"); } else { - builder.AppendLine($" '{Issuer}'"); + builder.AppendLine($"'{Issuer}'"); } } } @@ -466,51 +466,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IssueOn), out propertyOverride); if (Optional.IsDefined(IssueOn) || hasPropertyOverride) { - builder.Append(" issueDate:"); + builder.Append(" issueDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(IssueOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationDate:"); + builder.Append(" expirationDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -518,50 +518,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsValid), out propertyOverride); if (Optional.IsDefined(IsValid) || hasPropertyOverride) { - builder.Append(" valid:"); + builder.Append(" valid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsValid.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CerBlob), out propertyOverride); if (Optional.IsDefined(CerBlob) || hasPropertyOverride) { - builder.Append(" cerBlob:"); + builder.Append(" cerBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CerBlob.ToString()}'"); + builder.AppendLine($"'{CerBlob.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicKeyHash), out propertyOverride); if (Optional.IsDefined(PublicKeyHash) || hasPropertyOverride) { - builder.Append(" publicKeyHash:"); + builder.Append(" publicKeyHash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicKeyHash.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicKeyHash}'''"); } else { - builder.AppendLine($" '{PublicKeyHash}'"); + builder.AppendLine($"'{PublicKeyHash}'"); } } } @@ -569,49 +569,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultId), out propertyOverride); if (Optional.IsDefined(KeyVaultId) || hasPropertyOverride) { - builder.Append(" keyVaultId:"); + builder.Append(" keyVaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultId.ToString()}'"); + builder.AppendLine($"'{KeyVaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretName), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretName) || hasPropertyOverride) { - builder.Append(" keyVaultSecretName:"); + builder.Append(" keyVaultSecretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultSecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultSecretName}'''"); } else { - builder.AppendLine($" '{KeyVaultSecretName}'"); + builder.AppendLine($"'{KeyVaultSecretName}'"); } } } @@ -619,49 +619,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretStatus), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretStatus) || hasPropertyOverride) { - builder.Append(" keyVaultSecretStatus:"); + builder.Append(" keyVaultSecretStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultSecretStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{KeyVaultSecretStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerFarmId), out propertyOverride); if (Optional.IsDefined(ServerFarmId) || hasPropertyOverride) { - builder.Append(" serverFarmId:"); + builder.Append(" serverFarmId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerFarmId.ToString()}'"); + builder.AppendLine($"'{ServerFarmId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanonicalName), out propertyOverride); if (Optional.IsDefined(CanonicalName) || hasPropertyOverride) { - builder.Append(" canonicalName:"); + builder.Append(" canonicalName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CanonicalName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CanonicalName}'''"); } else { - builder.AppendLine($" '{CanonicalName}'"); + builder.AppendLine($"'{CanonicalName}'"); } } } @@ -669,21 +669,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainValidationMethod), out propertyOverride); if (Optional.IsDefined(DomainValidationMethod) || hasPropertyOverride) { - builder.Append(" domainValidationMethod:"); + builder.Append(" domainValidationMethod: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainValidationMethod.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainValidationMethod}'''"); } else { - builder.AppendLine($" '{DomainValidationMethod}'"); + builder.AppendLine($"'{DomainValidationMethod}'"); } } } @@ -693,12 +693,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -719,13 +722,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppInsightsWebAppStackSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppInsightsWebAppStackSettings.Serialization.cs index c1042c021f458..4338fbf89cbc4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppInsightsWebAppStackSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppInsightsWebAppStackSettings.Serialization.cs @@ -123,30 +123,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSupported), out propertyOverride); if (Optional.IsDefined(IsSupported) || hasPropertyOverride) { - builder.Append(" isSupported:"); + builder.Append(" isSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefaultOff), out propertyOverride); if (Optional.IsDefined(IsDefaultOff) || hasPropertyOverride) { - builder.Append(" isDefaultOff:"); + builder.Append(" isDefaultOff: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefaultOff.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -154,12 +154,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -180,13 +183,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppLogsConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppLogsConfiguration.Serialization.cs index a3193bdb63a10..4cc9824e05e62 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppLogsConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppLogsConfiguration.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Destination), out propertyOverride); if (Optional.IsDefined(Destination) || hasPropertyOverride) { - builder.Append(" destination:"); + builder.Append(" destination: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Destination.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Destination}'''"); } else { - builder.AppendLine($" '{Destination}'"); + builder.AppendLine($"'{Destination}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogAnalyticsConfiguration), out propertyOverride); if (Optional.IsDefined(LogAnalyticsConfiguration) || hasPropertyOverride) { - builder.Append(" logAnalyticsConfiguration:"); + builder.Append(" logAnalyticsConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LogAnalyticsConfiguration, options, 2, false); + AppendChildObject(builder, LogAnalyticsConfiguration, options, 2, false, " logAnalyticsConfiguration: "); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppRegistration.Serialization.cs index 6670315a43fd4..4ea0315ec3e5f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppRegistration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppId), out propertyOverride); if (Optional.IsDefined(AppId) || hasPropertyOverride) { - builder.Append(" appId:"); + builder.Append(" appId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppId}'''"); } else { - builder.AppendLine($" '{AppId}'"); + builder.AppendLine($"'{AppId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppSecretSettingName), out propertyOverride); if (Optional.IsDefined(AppSecretSettingName) || hasPropertyOverride) { - builder.Append(" appSecretSettingName:"); + builder.Append(" appSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppSecretSettingName}'''"); } else { - builder.AppendLine($" '{AppSecretSettingName}'"); + builder.AppendLine($"'{AppSecretSettingName}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadAllowedPrincipals.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadAllowedPrincipals.Serialization.cs index b8b2c8051790f..86e40d0b999f6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadAllowedPrincipals.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadAllowedPrincipals.Serialization.cs @@ -146,14 +146,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Groups.Any() || hasPropertyOverride) { - builder.Append(" groups:"); + builder.Append(" groups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Groups) { if (item == null) @@ -181,14 +181,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Identities.Any() || hasPropertyOverride) { - builder.Append(" identities:"); + builder.Append(" identities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Identities) { if (item == null) @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadLoginFlow.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadLoginFlow.Serialization.cs index 42ef4df603ea9..471316766f339 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadLoginFlow.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadLoginFlow.Serialization.cs @@ -136,14 +136,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LoginParameters.Any() || hasPropertyOverride) { - builder.Append(" loginParameters:"); + builder.Append(" loginParameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LoginParameters) { if (item == null) @@ -169,15 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsWwwAuthenticateDisabled), out propertyOverride); if (Optional.IsDefined(IsWwwAuthenticateDisabled) || hasPropertyOverride) { - builder.Append(" disableWWWAuthenticate:"); + builder.Append(" disableWWWAuthenticate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsWwwAuthenticateDisabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadProvider.Serialization.cs index 3a13eb951d04f..92b9050c1c335 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadProvider.Serialization.cs @@ -168,72 +168,72 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); if (Optional.IsDefined(Validation) || hasPropertyOverride) { - builder.Append(" validation:"); + builder.Append(" validation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Validation, options, 2, false); + AppendChildObject(builder, Validation, options, 2, false, " validation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoProvisioned), out propertyOverride); if (Optional.IsDefined(IsAutoProvisioned) || hasPropertyOverride) { - builder.Append(" isAutoProvisioned:"); + builder.Append(" isAutoProvisioned: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoProvisioned.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -241,12 +241,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -267,13 +270,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadRegistration.Serialization.cs index 55f23f8fa3f13..f80b7c8cb48d2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadRegistration.Serialization.cs @@ -159,21 +159,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OpenIdIssuer), out propertyOverride); if (Optional.IsDefined(OpenIdIssuer) || hasPropertyOverride) { - builder.Append(" openIdIssuer:"); + builder.Append(" openIdIssuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OpenIdIssuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OpenIdIssuer}'''"); } else { - builder.AppendLine($" '{OpenIdIssuer}'"); + builder.AppendLine($"'{OpenIdIssuer}'"); } } } @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" clientSecretSettingName:"); + builder.Append(" clientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{ClientSecretSettingName}'"); + builder.AppendLine($"'{ClientSecretSettingName}'"); } } } @@ -225,21 +225,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateThumbprintString), out propertyOverride); if (Optional.IsDefined(ClientSecretCertificateThumbprintString) || hasPropertyOverride) { - builder.Append(" clientSecretCertificateThumbprint:"); + builder.Append(" clientSecretCertificateThumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretCertificateThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretCertificateThumbprintString}'''"); } else { - builder.AppendLine($" '{ClientSecretCertificateThumbprintString}'"); + builder.AppendLine($"'{ClientSecretCertificateThumbprintString}'"); } } } @@ -247,21 +247,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateSubjectAlternativeName), out propertyOverride); if (Optional.IsDefined(ClientSecretCertificateSubjectAlternativeName) || hasPropertyOverride) { - builder.Append(" clientSecretCertificateSubjectAlternativeName:"); + builder.Append(" clientSecretCertificateSubjectAlternativeName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretCertificateSubjectAlternativeName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretCertificateSubjectAlternativeName}'''"); } else { - builder.AppendLine($" '{ClientSecretCertificateSubjectAlternativeName}'"); + builder.AppendLine($"'{ClientSecretCertificateSubjectAlternativeName}'"); } } } @@ -269,21 +269,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateIssuer), out propertyOverride); if (Optional.IsDefined(ClientSecretCertificateIssuer) || hasPropertyOverride) { - builder.Append(" clientSecretCertificateIssuer:"); + builder.Append(" clientSecretCertificateIssuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretCertificateIssuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretCertificateIssuer}'''"); } else { - builder.AppendLine($" '{ClientSecretCertificateIssuer}'"); + builder.AppendLine($"'{ClientSecretCertificateIssuer}'"); } } } @@ -292,12 +292,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -318,13 +321,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadValidation.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadValidation.Serialization.cs index c8798aac25027..23d5d3330d01b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadValidation.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAadValidation.Serialization.cs @@ -149,14 +149,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JwtClaimChecks), out propertyOverride); if (Optional.IsDefined(JwtClaimChecks) || hasPropertyOverride) { - builder.Append(" jwtClaimChecks:"); + builder.Append(" jwtClaimChecks: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, JwtClaimChecks, options, 2, false); + AppendChildObject(builder, JwtClaimChecks, options, 2, false, " jwtClaimChecks: "); } } @@ -165,14 +165,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedAudiences.Any() || hasPropertyOverride) { - builder.Append(" allowedAudiences:"); + builder.Append(" allowedAudiences: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedAudiences) { if (item == null) @@ -198,14 +198,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAuthorizationPolicy), out propertyOverride); if (Optional.IsDefined(DefaultAuthorizationPolicy) || hasPropertyOverride) { - builder.Append(" defaultAuthorizationPolicy:"); + builder.Append(" defaultAuthorizationPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DefaultAuthorizationPolicy, options, 2, false); + AppendChildObject(builder, DefaultAuthorizationPolicy, options, 2, false, " defaultAuthorizationPolicy: "); } } @@ -213,12 +213,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -239,13 +242,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiDefinitionInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiDefinitionInfo.Serialization.cs index a913f060dff55..3a10c4345c46e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiDefinitionInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiDefinitionInfo.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiKeyVaultReferenceList.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiKeyVaultReferenceList.Serialization.cs index 27dc24aff83dc..ab4050b76b6b8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiKeyVaultReferenceList.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceApiKeyVaultReferenceList.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleProvider.Serialization.cs index ff555a440d3cf..b26cc8b9253f1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleProvider.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleRegistration.Serialization.cs index 5265289b5631e..7af68f55233ff 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceAppleRegistration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" clientSecretSettingName:"); + builder.Append(" clientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{ClientSecretSettingName}'"); + builder.AppendLine($"'{ClientSecretSettingName}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceArmPlan.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceArmPlan.Serialization.cs index 9456c46c6e57e..8d6fa5f85acd0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceArmPlan.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceArmPlan.Serialization.cs @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Publisher), out propertyOverride); if (Optional.IsDefined(Publisher) || hasPropertyOverride) { - builder.Append(" publisher:"); + builder.Append(" publisher: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Publisher.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Publisher}'''"); } else { - builder.AppendLine($" '{Publisher}'"); + builder.AppendLine($"'{Publisher}'"); } } } @@ -192,21 +192,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -214,21 +214,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PromotionCode), out propertyOverride); if (Optional.IsDefined(PromotionCode) || hasPropertyOverride) { - builder.Append(" promotionCode:"); + builder.Append(" promotionCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PromotionCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PromotionCode}'''"); } else { - builder.AppendLine($" '{PromotionCode}'"); + builder.AppendLine($"'{PromotionCode}'"); } } } @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -259,12 +259,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -285,13 +288,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeter.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeter.Serialization.cs index 94cb61ac83118..9c6eeb71b990a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeter.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeter.Serialization.cs @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -290,28 +290,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -320,49 +320,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MeterId), out propertyOverride); if (Optional.IsDefined(MeterId) || hasPropertyOverride) { - builder.Append(" meterId:"); + builder.Append(" meterId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MeterId.Value.ToString()}'"); + builder.AppendLine($"'{MeterId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BillingLocation), out propertyOverride); if (Optional.IsDefined(BillingLocation) || hasPropertyOverride) { - builder.Append(" billingLocation:"); + builder.Append(" billingLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BillingLocation.Value.ToString()}'"); + builder.AppendLine($"'{BillingLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShortName), out propertyOverride); if (Optional.IsDefined(ShortName) || hasPropertyOverride) { - builder.Append(" shortName:"); + builder.Append(" shortName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ShortName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ShortName}'''"); } else { - builder.AppendLine($" '{ShortName}'"); + builder.AppendLine($"'{ShortName}'"); } } } @@ -370,21 +370,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FriendlyName), out propertyOverride); if (Optional.IsDefined(FriendlyName) || hasPropertyOverride) { - builder.Append(" friendlyName:"); + builder.Append(" friendlyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FriendlyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FriendlyName}'''"); } else { - builder.AppendLine($" '{FriendlyName}'"); + builder.AppendLine($"'{FriendlyName}'"); } } } @@ -392,21 +392,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OSType), out propertyOverride); if (Optional.IsDefined(OSType) || hasPropertyOverride) { - builder.Append(" osType:"); + builder.Append(" osType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OSType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OSType}'''"); } else { - builder.AppendLine($" '{OSType}'"); + builder.AppendLine($"'{OSType}'"); } } } @@ -414,14 +414,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Multiplier), out propertyOverride); if (Optional.IsDefined(Multiplier) || hasPropertyOverride) { - builder.Append(" multiplier:"); + builder.Append(" multiplier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Multiplier.Value.ToString()}'"); + builder.AppendLine($"'{Multiplier.Value.ToString()}'"); } } @@ -430,12 +430,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -456,13 +459,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeterListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeterListResult.Serialization.cs index d1382bac21285..28bd3d7284c33 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeterListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBillingMeterListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageApplicationLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageApplicationLogsConfig.Serialization.cs index d4821aaaf15c2..12673c224a557 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageApplicationLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageApplicationLogsConfig.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.Value.ToSerialString()}'"); + builder.AppendLine($"'{Level.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasUri), out propertyOverride); if (Optional.IsDefined(SasUri) || hasPropertyOverride) { - builder.Append(" sasUrl:"); + builder.Append(" sasUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SasUri.AbsoluteUri}'"); + builder.AppendLine($"'{SasUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) { - builder.Append(" retentionInDays:"); + builder.Append(" retentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionInDays.Value}"); + builder.AppendLine($"{RetentionInDays.Value}"); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageHttpLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageHttpLogsConfig.Serialization.cs index 4fd0dec2773e4..39997598120ad 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageHttpLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageHttpLogsConfig.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasUri), out propertyOverride); if (Optional.IsDefined(SasUri) || hasPropertyOverride) { - builder.Append(" sasUrl:"); + builder.Append(" sasUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SasUri.AbsoluteUri}'"); + builder.AppendLine($"'{SasUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) { - builder.Append(" retentionInDays:"); + builder.Append(" retentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionInDays.Value}"); + builder.AppendLine($"{RetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageTokenStore.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageTokenStore.Serialization.cs index 99dd99ca2b463..36f37cb63c4f8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageTokenStore.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceBlobStorageTokenStore.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasUrlSettingName), out propertyOverride); if (Optional.IsDefined(SasUrlSettingName) || hasPropertyOverride) { - builder.Append(" sasUrlSettingName:"); + builder.Append(" sasUrlSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SasUrlSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SasUrlSettingName}'''"); } else { - builder.AppendLine($" '{SasUrlSettingName}'"); + builder.AppendLine($"'{SasUrlSettingName}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateDetails.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateDetails.Serialization.cs index f5a765a9126b7..4cd613aa9dba1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateDetails.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateDetails.Serialization.cs @@ -204,35 +204,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Version.Value}"); + builder.AppendLine($"{Version.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SerialNumber), out propertyOverride); if (Optional.IsDefined(SerialNumber) || hasPropertyOverride) { - builder.Append(" serialNumber:"); + builder.Append(" serialNumber: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SerialNumber.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SerialNumber}'''"); } else { - builder.AppendLine($" '{SerialNumber}'"); + builder.AppendLine($"'{SerialNumber}'"); } } } @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subject), out propertyOverride); if (Optional.IsDefined(Subject) || hasPropertyOverride) { - builder.Append(" subject:"); + builder.Append(" subject: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subject.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subject}'''"); } else { - builder.AppendLine($" '{Subject}'"); + builder.AppendLine($"'{Subject}'"); } } } @@ -284,51 +284,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); if (Optional.IsDefined(NotBefore) || hasPropertyOverride) { - builder.Append(" notBefore:"); + builder.Append(" notBefore: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotBefore.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotAfter), out propertyOverride); if (Optional.IsDefined(NotAfter) || hasPropertyOverride) { - builder.Append(" notAfter:"); + builder.Append(" notAfter: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotAfter.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SignatureAlgorithm), out propertyOverride); if (Optional.IsDefined(SignatureAlgorithm) || hasPropertyOverride) { - builder.Append(" signatureAlgorithm:"); + builder.Append(" signatureAlgorithm: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SignatureAlgorithm.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SignatureAlgorithm}'''"); } else { - builder.AppendLine($" '{SignatureAlgorithm}'"); + builder.AppendLine($"'{SignatureAlgorithm}'"); } } } @@ -336,21 +336,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); if (Optional.IsDefined(Issuer) || hasPropertyOverride) { - builder.Append(" issuer:"); + builder.Append(" issuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Issuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Issuer}'''"); } else { - builder.AppendLine($" '{Issuer}'"); + builder.AppendLine($"'{Issuer}'"); } } } @@ -358,21 +358,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RawData), out propertyOverride); if (Optional.IsDefined(RawData) || hasPropertyOverride) { - builder.Append(" rawData:"); + builder.Append(" rawData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RawData.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RawData}'''"); } else { - builder.AppendLine($" '{RawData}'"); + builder.AppendLine($"'{RawData}'"); } } } @@ -381,12 +381,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -407,13 +410,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateEmail.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateEmail.Serialization.cs index 4d4b95537c85a..afd06bd98c39a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateEmail.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateEmail.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EmailId), out propertyOverride); if (Optional.IsDefined(EmailId) || hasPropertyOverride) { - builder.Append(" emailId:"); + builder.Append(" emailId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EmailId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EmailId}'''"); } else { - builder.AppendLine($" '{EmailId}'"); + builder.AppendLine($"'{EmailId}'"); } } } @@ -290,15 +290,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeStamp), out propertyOverride); if (Optional.IsDefined(TimeStamp) || hasPropertyOverride) { - builder.Append(" timeStamp:"); + builder.Append(" timeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -307,12 +307,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -333,13 +336,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateListResult.Serialization.cs index f0e974fca9079..7729e8bf7c225 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderListResult.Serialization.cs index c9449d4919207..3c7f5acfcbc92 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderPatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderPatch.Serialization.cs index ee3f64d93f814..d07e05632f692 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderPatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateOrderPatch.Serialization.cs @@ -474,21 +474,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -496,21 +496,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -518,28 +518,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -550,18 +550,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Certificates.Any() || hasPropertyOverride) { - builder.Append(" certificates:"); + builder.Append(" certificates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Certificates) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " certificates: "); } builder.AppendLine(" }"); } @@ -571,21 +571,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DistinguishedName), out propertyOverride); if (Optional.IsDefined(DistinguishedName) || hasPropertyOverride) { - builder.Append(" distinguishedName:"); + builder.Append(" distinguishedName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DistinguishedName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DistinguishedName}'''"); } else { - builder.AppendLine($" '{DistinguishedName}'"); + builder.AppendLine($"'{DistinguishedName}'"); } } } @@ -593,21 +593,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainVerificationToken), out propertyOverride); if (Optional.IsDefined(DomainVerificationToken) || hasPropertyOverride) { - builder.Append(" domainVerificationToken:"); + builder.Append(" domainVerificationToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainVerificationToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainVerificationToken}'''"); } else { - builder.AppendLine($" '{DomainVerificationToken}'"); + builder.AppendLine($"'{DomainVerificationToken}'"); } } } @@ -615,120 +615,120 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidityInYears), out propertyOverride); if (Optional.IsDefined(ValidityInYears) || hasPropertyOverride) { - builder.Append(" validityInYears:"); + builder.Append(" validityInYears: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ValidityInYears.Value}"); + builder.AppendLine($"{ValidityInYears.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); if (Optional.IsDefined(KeySize) || hasPropertyOverride) { - builder.Append(" keySize:"); + builder.Append(" keySize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {KeySize.Value}"); + builder.AppendLine($"{KeySize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProductType), out propertyOverride); if (Optional.IsDefined(ProductType) || hasPropertyOverride) { - builder.Append(" productType:"); + builder.Append(" productType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProductType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProductType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRenew), out propertyOverride); if (Optional.IsDefined(IsAutoRenew) || hasPropertyOverride) { - builder.Append(" autoRenew:"); + builder.Append(" autoRenew: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRenew.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SignedCertificate), out propertyOverride); if (Optional.IsDefined(SignedCertificate) || hasPropertyOverride) { - builder.Append(" signedCertificate:"); + builder.Append(" signedCertificate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SignedCertificate, options, 4, false); + AppendChildObject(builder, SignedCertificate, options, 4, false, " signedCertificate: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Csr), out propertyOverride); if (Optional.IsDefined(Csr) || hasPropertyOverride) { - builder.Append(" csr:"); + builder.Append(" csr: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Csr.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Csr}'''"); } else { - builder.AppendLine($" '{Csr}'"); + builder.AppendLine($"'{Csr}'"); } } } @@ -736,49 +736,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Intermediate), out propertyOverride); if (Optional.IsDefined(Intermediate) || hasPropertyOverride) { - builder.Append(" intermediate:"); + builder.Append(" intermediate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Intermediate, options, 4, false); + AppendChildObject(builder, Intermediate, options, 4, false, " intermediate: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Root), out propertyOverride); if (Optional.IsDefined(Root) || hasPropertyOverride) { - builder.Append(" root:"); + builder.Append(" root: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Root, options, 4, false); + AppendChildObject(builder, Root, options, 4, false, " root: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SerialNumber), out propertyOverride); if (Optional.IsDefined(SerialNumber) || hasPropertyOverride) { - builder.Append(" serialNumber:"); + builder.Append(" serialNumber: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SerialNumber.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SerialNumber}'''"); } else { - builder.AppendLine($" '{SerialNumber}'"); + builder.AppendLine($"'{SerialNumber}'"); } } } @@ -786,45 +786,45 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastCertificateIssuanceOn), out propertyOverride); if (Optional.IsDefined(LastCertificateIssuanceOn) || hasPropertyOverride) { - builder.Append(" lastCertificateIssuanceTime:"); + builder.Append(" lastCertificateIssuanceTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastCertificateIssuanceOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrivateKeyExternal), out propertyOverride); if (Optional.IsDefined(IsPrivateKeyExternal) || hasPropertyOverride) { - builder.Append(" isPrivateKeyExternal:"); + builder.Append(" isPrivateKeyExternal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrivateKeyExternal.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -833,14 +833,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppServiceCertificateNotRenewableReasons.Any() || hasPropertyOverride) { - builder.Append(" appServiceCertificateNotRenewableReasons:"); + builder.Append(" appServiceCertificateNotRenewableReasons: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AppServiceCertificateNotRenewableReasons) { builder.AppendLine($" '{item.ToString()}'"); @@ -853,29 +853,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextAutoRenewalTimeStamp), out propertyOverride); if (Optional.IsDefined(NextAutoRenewalTimeStamp) || hasPropertyOverride) { - builder.Append(" nextAutoRenewalTimeStamp:"); + builder.Append(" nextAutoRenewalTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextAutoRenewalTimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Contact), out propertyOverride); if (Optional.IsDefined(Contact) || hasPropertyOverride) { - builder.Append(" contact:"); + builder.Append(" contact: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Contact, options, 4, false); + AppendChildObject(builder, Contact, options, 4, false, " contact: "); } } @@ -884,12 +884,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -910,13 +913,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificatePatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificatePatch.Serialization.cs index a8bf14ce00095..e3e2b3adc8230 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificatePatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificatePatch.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -253,28 +253,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -283,35 +283,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultId), out propertyOverride); if (Optional.IsDefined(KeyVaultId) || hasPropertyOverride) { - builder.Append(" keyVaultId:"); + builder.Append(" keyVaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultId.ToString()}'"); + builder.AppendLine($"'{KeyVaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretName), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretName) || hasPropertyOverride) { - builder.Append(" keyVaultSecretName:"); + builder.Append(" keyVaultSecretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultSecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultSecretName}'''"); } else { - builder.AppendLine($" '{KeyVaultSecretName}'"); + builder.AppendLine($"'{KeyVaultSecretName}'"); } } } @@ -319,14 +319,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateProperties.Serialization.cs index d200f09a6e895..a6a4ef82f1f6a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCertificateProperties.Serialization.cs @@ -134,35 +134,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultId), out propertyOverride); if (Optional.IsDefined(KeyVaultId) || hasPropertyOverride) { - builder.Append(" keyVaultId:"); + builder.Append(" keyVaultId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KeyVaultId.ToString()}'"); + builder.AppendLine($"'{KeyVaultId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultSecretName), out propertyOverride); if (Optional.IsDefined(KeyVaultSecretName) || hasPropertyOverride) { - builder.Append(" keyVaultSecretName:"); + builder.Append(" keyVaultSecretName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultSecretName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultSecretName}'''"); } else { - builder.AppendLine($" '{KeyVaultSecretName}'"); + builder.AppendLine($"'{KeyVaultSecretName}'"); } } } @@ -170,14 +170,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceConfigurationDictionary.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceConfigurationDictionary.Serialization.cs index 13a1a57816ca5..9e7b10e3f5f66 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceConfigurationDictionary.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceConfigurationDictionary.Serialization.cs @@ -180,21 +180,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -204,17 +204,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Properties) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -222,12 +222,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -260,28 +260,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -289,12 +289,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -315,13 +318,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCorsSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCorsSettings.Serialization.cs index eaa5bbb1da9ae..ce31c39887599 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCorsSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceCorsSettings.Serialization.cs @@ -136,14 +136,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedOrigins.Any() || hasPropertyOverride) { - builder.Append(" allowedOrigins:"); + builder.Append(" allowedOrigins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedOrigins) { if (item == null) @@ -169,15 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsCredentialsSupported), out propertyOverride); if (Optional.IsDefined(IsCredentialsSupported) || hasPropertyOverride) { - builder.Append(" supportCredentials:"); + builder.Append(" supportCredentials: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsCredentialsSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDatabaseBackupSetting.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDatabaseBackupSetting.Serialization.cs index a0592ed96ad2f..04da33f9b9fc1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDatabaseBackupSetting.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDatabaseBackupSetting.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,35 +156,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseType), out propertyOverride); if (Optional.IsDefined(DatabaseType) || hasPropertyOverride) { - builder.Append(" databaseType:"); + builder.Append(" databaseType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DatabaseType.ToString()}'"); + builder.AppendLine($"'{DatabaseType.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionStringName), out propertyOverride); if (Optional.IsDefined(ConnectionStringName) || hasPropertyOverride) { - builder.Append(" connectionStringName:"); + builder.Append(" connectionStringName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionStringName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionStringName}'''"); } else { - builder.AppendLine($" '{ConnectionStringName}'"); + builder.AppendLine($"'{ConnectionStringName}'"); } } } @@ -192,21 +192,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionString), out propertyOverride); if (Optional.IsDefined(ConnectionString) || hasPropertyOverride) { - builder.Append(" connectionString:"); + builder.Append(" connectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionString}'''"); } else { - builder.AppendLine($" '{ConnectionString}'"); + builder.AppendLine($"'{ConnectionString}'"); } } } @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDeploymentLocations.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDeploymentLocations.Serialization.cs index 373f13baba32c..2e6b48ea7a5aa 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDeploymentLocations.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDeploymentLocations.Serialization.cs @@ -171,17 +171,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Locations.Any() || hasPropertyOverride) { - builder.Append(" locations:"); + builder.Append(" locations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Locations) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " locations: "); } builder.AppendLine(" ]"); } @@ -193,17 +193,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostingEnvironments.Any() || hasPropertyOverride) { - builder.Append(" hostingEnvironments:"); + builder.Append(" hostingEnvironments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostingEnvironments) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " hostingEnvironments: "); } builder.AppendLine(" ]"); } @@ -215,17 +215,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostingEnvironmentDeploymentInfos.Any() || hasPropertyOverride) { - builder.Append(" hostingEnvironmentDeploymentInfos:"); + builder.Append(" hostingEnvironmentDeploymentInfos: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostingEnvironmentDeploymentInfos) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " hostingEnvironmentDeploymentInfos: "); } builder.AppendLine(" ]"); } @@ -236,12 +236,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -262,13 +265,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDetectorListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDetectorListResult.Serialization.cs index ea477a89089eb..b91b03b0da34b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDetectorListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDetectorListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainListResult.Serialization.cs index 5206df551a709..df1752e37f4fe 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifier.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifier.Serialization.cs index de73be952a773..b80ab9402601b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifier.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifier.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifierListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifierListResult.Serialization.cs index 9be8eafb4ffb5..dc54e4388d03e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifierListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainNameIdentifierListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainPatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainPatch.Serialization.cs index bbec793d2b537..447e603cc9ca7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainPatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceDomainPatch.Serialization.cs @@ -491,21 +491,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -513,21 +513,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -535,28 +535,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -565,84 +565,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactAdmin), out propertyOverride); if (Optional.IsDefined(ContactAdmin) || hasPropertyOverride) { - builder.Append(" contactAdmin:"); + builder.Append(" contactAdmin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactAdmin, options, 4, false); + AppendChildObject(builder, ContactAdmin, options, 4, false, " contactAdmin: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactBilling), out propertyOverride); if (Optional.IsDefined(ContactBilling) || hasPropertyOverride) { - builder.Append(" contactBilling:"); + builder.Append(" contactBilling: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactBilling, options, 4, false); + AppendChildObject(builder, ContactBilling, options, 4, false, " contactBilling: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactRegistrant), out propertyOverride); if (Optional.IsDefined(ContactRegistrant) || hasPropertyOverride) { - builder.Append(" contactRegistrant:"); + builder.Append(" contactRegistrant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactRegistrant, options, 4, false); + AppendChildObject(builder, ContactRegistrant, options, 4, false, " contactRegistrant: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContactTech), out propertyOverride); if (Optional.IsDefined(ContactTech) || hasPropertyOverride) { - builder.Append(" contactTech:"); + builder.Append(" contactTech: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContactTech, options, 4, false); + AppendChildObject(builder, ContactTech, options, 4, false, " contactTech: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistrationStatus), out propertyOverride); if (Optional.IsDefined(RegistrationStatus) || hasPropertyOverride) { - builder.Append(" registrationStatus:"); + builder.Append(" registrationStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RegistrationStatus.Value.ToSerialString()}'"); + builder.AppendLine($"'{RegistrationStatus.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } @@ -651,14 +651,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NameServers.Any() || hasPropertyOverride) { - builder.Append(" nameServers:"); + builder.Append(" nameServers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NameServers) { if (item == null) @@ -684,90 +684,90 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDomainPrivacyEnabled), out propertyOverride); if (Optional.IsDefined(IsDomainPrivacyEnabled) || hasPropertyOverride) { - builder.Append(" privacy:"); + builder.Append(" privacy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDomainPrivacyEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdTime:"); + builder.Append(" createdTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRenewedOn), out propertyOverride); if (Optional.IsDefined(LastRenewedOn) || hasPropertyOverride) { - builder.Append(" lastRenewedTime:"); + builder.Append(" lastRenewedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastRenewedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoRenew), out propertyOverride); if (Optional.IsDefined(IsAutoRenew) || hasPropertyOverride) { - builder.Append(" autoRenew:"); + builder.Append(" autoRenew: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoRenew.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReadyForDnsRecordManagement), out propertyOverride); if (Optional.IsDefined(IsReadyForDnsRecordManagement) || hasPropertyOverride) { - builder.Append(" readyForDnsRecordManagement:"); + builder.Append(" readyForDnsRecordManagement: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReadyForDnsRecordManagement.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -776,17 +776,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ManagedHostNames.Any() || hasPropertyOverride) { - builder.Append(" managedHostNames:"); + builder.Append(" managedHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ManagedHostNames) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " managedHostNames: "); } builder.AppendLine(" ]"); } @@ -796,14 +796,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Consent), out propertyOverride); if (Optional.IsDefined(Consent) || hasPropertyOverride) { - builder.Append(" consent:"); + builder.Append(" consent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Consent, options, 4, false); + AppendChildObject(builder, Consent, options, 4, false, " consent: "); } } @@ -812,14 +812,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DomainNotRenewableReasons.Any() || hasPropertyOverride) { - builder.Append(" domainNotRenewableReasons:"); + builder.Append(" domainNotRenewableReasons: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DomainNotRenewableReasons) { builder.AppendLine($" '{item.ToString()}'"); @@ -832,35 +832,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsType), out propertyOverride); if (Optional.IsDefined(DnsType) || hasPropertyOverride) { - builder.Append(" dnsType:"); + builder.Append(" dnsType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DnsType.Value.ToSerialString()}'"); + builder.AppendLine($"'{DnsType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsZoneId), out propertyOverride); if (Optional.IsDefined(DnsZoneId) || hasPropertyOverride) { - builder.Append(" dnsZoneId:"); + builder.Append(" dnsZoneId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsZoneId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsZoneId}'''"); } else { - builder.AppendLine($" '{DnsZoneId}'"); + builder.AppendLine($"'{DnsZoneId}'"); } } } @@ -868,35 +868,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetDnsType), out propertyOverride); if (Optional.IsDefined(TargetDnsType) || hasPropertyOverride) { - builder.Append(" targetDnsType:"); + builder.Append(" targetDnsType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TargetDnsType.Value.ToSerialString()}'"); + builder.AppendLine($"'{TargetDnsType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthCode), out propertyOverride); if (Optional.IsDefined(AuthCode) || hasPropertyOverride) { - builder.Append(" authCode:"); + builder.Append(" authCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthCode}'''"); } else { - builder.AppendLine($" '{AuthCode}'"); + builder.AppendLine($"'{AuthCode}'"); } } } @@ -906,12 +906,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -932,13 +935,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDependency.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDependency.Serialization.cs index bcb22627e04a8..fe92f1d36f4de 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDependency.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDependency.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainName), out propertyOverride); if (Optional.IsDefined(DomainName) || hasPropertyOverride) { - builder.Append(" domainName:"); + builder.Append(" domainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainName}'''"); } else { - builder.AppendLine($" '{DomainName}'"); + builder.AppendLine($"'{DomainName}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EndpointDetails.Any() || hasPropertyOverride) { - builder.Append(" endpointDetails:"); + builder.Append(" endpointDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EndpointDetails) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " endpointDetails: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDetail.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDetail.Serialization.cs index f09572c63747c..708fd7085a5d9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDetail.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEndpointDetail.Serialization.cs @@ -154,57 +154,57 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPAddress), out propertyOverride); if (Optional.IsDefined(IPAddress) || hasPropertyOverride) { - builder.Append(" ipAddress:"); + builder.Append(" ipAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IPAddress.ToString()}'"); + builder.AppendLine($"'{IPAddress.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); if (Optional.IsDefined(Port) || hasPropertyOverride) { - builder.Append(" port:"); + builder.Append(" port: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Port.Value}"); + builder.AppendLine($"{Port.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Latency), out propertyOverride); if (Optional.IsDefined(Latency) || hasPropertyOverride) { - builder.Append(" latency:"); + builder.Append(" latency: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Latency.Value.ToString()}'"); + builder.AppendLine($"'{Latency.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAccessible), out propertyOverride); if (Optional.IsDefined(IsAccessible) || hasPropertyOverride) { - builder.Append(" isAccessible:"); + builder.Append(" isAccessible: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAccessible.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -212,12 +212,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -238,13 +241,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentAddressResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentAddressResult.Serialization.cs index 6f033f0f9ed31..022b854455163 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentAddressResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentAddressResult.Serialization.cs @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -306,28 +306,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -336,28 +336,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceIPAddress), out propertyOverride); if (Optional.IsDefined(ServiceIPAddress) || hasPropertyOverride) { - builder.Append(" serviceIpAddress:"); + builder.Append(" serviceIpAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServiceIPAddress.ToString()}'"); + builder.AppendLine($"'{ServiceIPAddress.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalIPAddress), out propertyOverride); if (Optional.IsDefined(InternalIPAddress) || hasPropertyOverride) { - builder.Append(" internalIpAddress:"); + builder.Append(" internalIpAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InternalIPAddress.ToString()}'"); + builder.AppendLine($"'{InternalIPAddress.ToString()}'"); } } @@ -366,14 +366,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (OutboundIPAddresses.Any() || hasPropertyOverride) { - builder.Append(" outboundIpAddresses:"); + builder.Append(" outboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in OutboundIPAddresses) { if (item == null) @@ -393,17 +393,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualIPMappings.Any() || hasPropertyOverride) { - builder.Append(" vipMappings:"); + builder.Append(" vipMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualIPMappings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " vipMappings: "); } builder.AppendLine(" ]"); } @@ -415,12 +415,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -441,13 +444,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentListResult.Serialization.cs index c1176fb85dc12..3b124d4910283 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentPatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentPatch.Serialization.cs index a040f96a04291..734981beb9ddb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentPatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentPatch.Serialization.cs @@ -421,21 +421,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -443,21 +443,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -465,28 +465,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -495,77 +495,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetwork), out propertyOverride); if (Optional.IsDefined(VirtualNetwork) || hasPropertyOverride) { - builder.Append(" virtualNetwork:"); + builder.Append(" virtualNetwork: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, VirtualNetwork, options, 4, false); + AppendChildObject(builder, VirtualNetwork, options, 4, false, " virtualNetwork: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalLoadBalancingMode), out propertyOverride); if (Optional.IsDefined(InternalLoadBalancingMode) || hasPropertyOverride) { - builder.Append(" internalLoadBalancingMode:"); + builder.Append(" internalLoadBalancingMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InternalLoadBalancingMode.Value.ToString()}'"); + builder.AppendLine($"'{InternalLoadBalancingMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiSize), out propertyOverride); if (Optional.IsDefined(MultiSize) || hasPropertyOverride) { - builder.Append(" multiSize:"); + builder.Append(" multiSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MultiSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MultiSize}'''"); } else { - builder.AppendLine($" '{MultiSize}'"); + builder.AppendLine($"'{MultiSize}'"); } } } @@ -573,49 +573,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiRoleCount), out propertyOverride); if (Optional.IsDefined(MultiRoleCount) || hasPropertyOverride) { - builder.Append(" multiRoleCount:"); + builder.Append(" multiRoleCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MultiRoleCount.Value}"); + builder.AppendLine($"{MultiRoleCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPSslAddressCount), out propertyOverride); if (Optional.IsDefined(IPSslAddressCount) || hasPropertyOverride) { - builder.Append(" ipsslAddressCount:"); + builder.Append(" ipsslAddressCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {IPSslAddressCount.Value}"); + builder.AppendLine($"{IPSslAddressCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsSuffix), out propertyOverride); if (Optional.IsDefined(DnsSuffix) || hasPropertyOverride) { - builder.Append(" dnsSuffix:"); + builder.Append(" dnsSuffix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsSuffix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsSuffix}'''"); } else { - builder.AppendLine($" '{DnsSuffix}'"); + builder.AppendLine($"'{DnsSuffix}'"); } } } @@ -623,43 +623,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNumberOfMachines), out propertyOverride); if (Optional.IsDefined(MaximumNumberOfMachines) || hasPropertyOverride) { - builder.Append(" maximumNumberOfMachines:"); + builder.Append(" maximumNumberOfMachines: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumNumberOfMachines.Value}"); + builder.AppendLine($"{MaximumNumberOfMachines.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrontEndScaleFactor), out propertyOverride); if (Optional.IsDefined(FrontEndScaleFactor) || hasPropertyOverride) { - builder.Append(" frontEndScaleFactor:"); + builder.Append(" frontEndScaleFactor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FrontEndScaleFactor.Value}"); + builder.AppendLine($"{FrontEndScaleFactor.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSuspended), out propertyOverride); if (Optional.IsDefined(IsSuspended) || hasPropertyOverride) { - builder.Append(" suspended:"); + builder.Append(" suspended: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSuspended.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -668,17 +668,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ClusterSettings.Any() || hasPropertyOverride) { - builder.Append(" clusterSettings:"); + builder.Append(" clusterSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ClusterSettings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " clusterSettings: "); } builder.AppendLine(" ]"); } @@ -690,14 +690,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserWhitelistedIPRanges.Any() || hasPropertyOverride) { - builder.Append(" userWhitelistedIpRanges:"); + builder.Append(" userWhitelistedIpRanges: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserWhitelistedIPRanges) { if (item == null) @@ -723,44 +723,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLinuxWorkers), out propertyOverride); if (Optional.IsDefined(HasLinuxWorkers) || hasPropertyOverride) { - builder.Append(" hasLinuxWorkers:"); + builder.Append(" hasLinuxWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLinuxWorkers.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DedicatedHostCount), out propertyOverride); if (Optional.IsDefined(DedicatedHostCount) || hasPropertyOverride) { - builder.Append(" dedicatedHostCount:"); + builder.Append(" dedicatedHostCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DedicatedHostCount.Value}"); + builder.AppendLine($"{DedicatedHostCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -769,12 +769,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -795,13 +798,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentProperties.Serialization.cs index a6897b2c1bc80..b996ea21f2d74 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceEnvironmentProperties.Serialization.cs @@ -339,77 +339,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetwork), out propertyOverride); if (Optional.IsDefined(VirtualNetwork) || hasPropertyOverride) { - builder.Append(" virtualNetwork:"); + builder.Append(" virtualNetwork: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, VirtualNetwork, options, 2, false); + AppendChildObject(builder, VirtualNetwork, options, 2, false, " virtualNetwork: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalLoadBalancingMode), out propertyOverride); if (Optional.IsDefined(InternalLoadBalancingMode) || hasPropertyOverride) { - builder.Append(" internalLoadBalancingMode:"); + builder.Append(" internalLoadBalancingMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InternalLoadBalancingMode.Value.ToString()}'"); + builder.AppendLine($"'{InternalLoadBalancingMode.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiSize), out propertyOverride); if (Optional.IsDefined(MultiSize) || hasPropertyOverride) { - builder.Append(" multiSize:"); + builder.Append(" multiSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MultiSize.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MultiSize}'''"); } else { - builder.AppendLine($" '{MultiSize}'"); + builder.AppendLine($"'{MultiSize}'"); } } } @@ -417,49 +417,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MultiRoleCount), out propertyOverride); if (Optional.IsDefined(MultiRoleCount) || hasPropertyOverride) { - builder.Append(" multiRoleCount:"); + builder.Append(" multiRoleCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MultiRoleCount.Value}"); + builder.AppendLine($"{MultiRoleCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPSslAddressCount), out propertyOverride); if (Optional.IsDefined(IPSslAddressCount) || hasPropertyOverride) { - builder.Append(" ipsslAddressCount:"); + builder.Append(" ipsslAddressCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {IPSslAddressCount.Value}"); + builder.AppendLine($"{IPSslAddressCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsSuffix), out propertyOverride); if (Optional.IsDefined(DnsSuffix) || hasPropertyOverride) { - builder.Append(" dnsSuffix:"); + builder.Append(" dnsSuffix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsSuffix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsSuffix}'''"); } else { - builder.AppendLine($" '{DnsSuffix}'"); + builder.AppendLine($"'{DnsSuffix}'"); } } } @@ -467,43 +467,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNumberOfMachines), out propertyOverride); if (Optional.IsDefined(MaximumNumberOfMachines) || hasPropertyOverride) { - builder.Append(" maximumNumberOfMachines:"); + builder.Append(" maximumNumberOfMachines: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumNumberOfMachines.Value}"); + builder.AppendLine($"{MaximumNumberOfMachines.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrontEndScaleFactor), out propertyOverride); if (Optional.IsDefined(FrontEndScaleFactor) || hasPropertyOverride) { - builder.Append(" frontEndScaleFactor:"); + builder.Append(" frontEndScaleFactor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FrontEndScaleFactor.Value}"); + builder.AppendLine($"{FrontEndScaleFactor.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSuspended), out propertyOverride); if (Optional.IsDefined(IsSuspended) || hasPropertyOverride) { - builder.Append(" suspended:"); + builder.Append(" suspended: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSuspended.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -512,17 +512,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ClusterSettings.Any() || hasPropertyOverride) { - builder.Append(" clusterSettings:"); + builder.Append(" clusterSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ClusterSettings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " clusterSettings: "); } builder.AppendLine(" ]"); } @@ -534,14 +534,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserWhitelistedIPRanges.Any() || hasPropertyOverride) { - builder.Append(" userWhitelistedIpRanges:"); + builder.Append(" userWhitelistedIpRanges: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserWhitelistedIPRanges) { if (item == null) @@ -567,44 +567,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasLinuxWorkers), out propertyOverride); if (Optional.IsDefined(HasLinuxWorkers) || hasPropertyOverride) { - builder.Append(" hasLinuxWorkers:"); + builder.Append(" hasLinuxWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasLinuxWorkers.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DedicatedHostCount), out propertyOverride); if (Optional.IsDefined(DedicatedHostCount) || hasPropertyOverride) { - builder.Append(" dedicatedHostCount:"); + builder.Append(" dedicatedHostCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DedicatedHostCount.Value}"); + builder.AppendLine($"{DedicatedHostCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -612,12 +612,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -638,13 +641,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceFacebookProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceFacebookProvider.Serialization.cs index 7eb521cf6c664..460135589cd0f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceFacebookProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceFacebookProvider.Serialization.cs @@ -149,50 +149,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GraphApiVersion), out propertyOverride); if (Optional.IsDefined(GraphApiVersion) || hasPropertyOverride) { - builder.Append(" graphApiVersion:"); + builder.Append(" graphApiVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GraphApiVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GraphApiVersion}'''"); } else { - builder.AppendLine($" '{GraphApiVersion}'"); + builder.AppendLine($"'{GraphApiVersion}'"); } } } @@ -200,14 +200,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceForwardProxy.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceForwardProxy.Serialization.cs index 9a5bce3f3943f..0933a81ff2458 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceForwardProxy.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceForwardProxy.Serialization.cs @@ -130,35 +130,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Convention), out propertyOverride); if (Optional.IsDefined(Convention) || hasPropertyOverride) { - builder.Append(" convention:"); + builder.Append(" convention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Convention.Value.ToSerialString()}'"); + builder.AppendLine($"'{Convention.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomHostHeaderName), out propertyOverride); if (Optional.IsDefined(CustomHostHeaderName) || hasPropertyOverride) { - builder.Append(" customHostHeaderName:"); + builder.Append(" customHostHeaderName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CustomHostHeaderName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CustomHostHeaderName}'''"); } else { - builder.AppendLine($" '{CustomHostHeaderName}'"); + builder.AppendLine($"'{CustomHostHeaderName}'"); } } } @@ -166,21 +166,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomProtoHeaderName), out propertyOverride); if (Optional.IsDefined(CustomProtoHeaderName) || hasPropertyOverride) { - builder.Append(" customProtoHeaderName:"); + builder.Append(" customProtoHeaderName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CustomProtoHeaderName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CustomProtoHeaderName}'''"); } else { - builder.AppendLine($" '{CustomProtoHeaderName}'"); + builder.AppendLine($"'{CustomProtoHeaderName}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegion.Serialization.cs index 2c6ce9d6dfb9c..380a70d56457c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegion.Serialization.cs @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -223,21 +223,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -245,28 +245,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -275,21 +275,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OrgDomain), out propertyOverride); if (Optional.IsDefined(OrgDomain) || hasPropertyOverride) { - builder.Append(" orgDomain:"); + builder.Append(" orgDomain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OrgDomain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OrgDomain}'''"); } else { - builder.AppendLine($" '{OrgDomain}'"); + builder.AppendLine($"'{OrgDomain}'"); } } } @@ -343,12 +343,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -369,13 +372,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegionListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegionListResult.Serialization.cs index 9b26f48ed978a..4bbe624dac35b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegionListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGeoRegionListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGitHubProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGitHubProvider.Serialization.cs index 0129de523e942..a3fcb16a6296b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGitHubProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGitHubProvider.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGoogleProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGoogleProvider.Serialization.cs index 59dc8a8952064..22c5b61db27d5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGoogleProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceGoogleProvider.Serialization.cs @@ -153,57 +153,57 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); if (Optional.IsDefined(Validation) || hasPropertyOverride) { - builder.Append(" validation:"); + builder.Append(" validation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Validation, options, 2, false); + AppendChildObject(builder, Validation, options, 2, false, " validation: "); } } @@ -211,12 +211,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -237,13 +240,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHostName.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHostName.Serialization.cs index 7b33144762983..b79e707480a34 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHostName.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHostName.Serialization.cs @@ -186,21 +186,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -210,14 +210,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SiteNames.Any() || hasPropertyOverride) { - builder.Append(" siteNames:"); + builder.Append(" siteNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SiteNames) { if (item == null) @@ -243,21 +243,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureResourceName), out propertyOverride); if (Optional.IsDefined(AzureResourceName) || hasPropertyOverride) { - builder.Append(" azureResourceName:"); + builder.Append(" azureResourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzureResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzureResourceName}'''"); } else { - builder.AppendLine($" '{AzureResourceName}'"); + builder.AppendLine($"'{AzureResourceName}'"); } } } @@ -265,42 +265,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureResourceType), out propertyOverride); if (Optional.IsDefined(AzureResourceType) || hasPropertyOverride) { - builder.Append(" azureResourceType:"); + builder.Append(" azureResourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AzureResourceType.Value.ToSerialString()}'"); + builder.AppendLine($"'{AzureResourceType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomHostNameDnsRecordType), out propertyOverride); if (Optional.IsDefined(CustomHostNameDnsRecordType) || hasPropertyOverride) { - builder.Append(" customHostNameDnsRecordType:"); + builder.Append(" customHostNameDnsRecordType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CustomHostNameDnsRecordType.Value.ToSerialString()}'"); + builder.AppendLine($"'{CustomHostNameDnsRecordType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostNameType), out propertyOverride); if (Optional.IsDefined(HostNameType) || hasPropertyOverride) { - builder.Append(" hostNameType:"); + builder.Append(" hostNameType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{HostNameType.Value.ToSerialString()}'"); + builder.AppendLine($"'{HostNameType.Value.ToSerialString()}'"); } } @@ -308,12 +308,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -334,13 +337,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpLogsConfig.Serialization.cs index a3fe9719ad801..cc637f744c3ea 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpLogsConfig.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileSystem), out propertyOverride); if (Optional.IsDefined(FileSystem) || hasPropertyOverride) { - builder.Append(" fileSystem:"); + builder.Append(" fileSystem: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, FileSystem, options, 2, false); + AppendChildObject(builder, FileSystem, options, 2, false, " fileSystem: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureBlobStorage), out propertyOverride); if (Optional.IsDefined(AzureBlobStorage) || hasPropertyOverride) { - builder.Append(" azureBlobStorage:"); + builder.Append(" azureBlobStorage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureBlobStorage, options, 2, false); + AppendChildObject(builder, AzureBlobStorage, options, 2, false, " azureBlobStorage: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettings.Serialization.cs index cae25d3e4c027..76a9397a56a66 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettings.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttpsRequired), out propertyOverride); if (Optional.IsDefined(IsHttpsRequired) || hasPropertyOverride) { - builder.Append(" requireHttps:"); + builder.Append(" requireHttps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttpsRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Routes), out propertyOverride); if (Optional.IsDefined(Routes) || hasPropertyOverride) { - builder.Append(" routes:"); + builder.Append(" routes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Routes, options, 2, false); + AppendChildObject(builder, Routes, options, 2, false, " routes: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForwardProxy), out propertyOverride); if (Optional.IsDefined(ForwardProxy) || hasPropertyOverride) { - builder.Append(" forwardProxy:"); + builder.Append(" forwardProxy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ForwardProxy, options, 2, false); + AppendChildObject(builder, ForwardProxy, options, 2, false, " forwardProxy: "); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettingsRoutes.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettingsRoutes.Serialization.cs index e67e1925d7726..8876d147f5b69 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettingsRoutes.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceHttpSettingsRoutes.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiPrefix), out propertyOverride); if (Optional.IsDefined(ApiPrefix) || hasPropertyOverride) { - builder.Append(" apiPrefix:"); + builder.Append(" apiPrefix: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApiPrefix.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApiPrefix}'''"); } else { - builder.AppendLine($" '{ApiPrefix}'"); + builder.AppendLine($"'{ApiPrefix}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIPSecurityRestriction.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIPSecurityRestriction.Serialization.cs index c1bc05c5d983d..53297bae7eedd 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIPSecurityRestriction.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIPSecurityRestriction.Serialization.cs @@ -272,21 +272,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -294,21 +294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPAddressOrCidr), out propertyOverride); if (Optional.IsDefined(IPAddressOrCidr) || hasPropertyOverride) { - builder.Append(" ipAddress:"); + builder.Append(" ipAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (IPAddressOrCidr.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{IPAddressOrCidr}'''"); } else { - builder.AppendLine($" '{IPAddressOrCidr}'"); + builder.AppendLine($"'{IPAddressOrCidr}'"); } } } @@ -316,21 +316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetMask), out propertyOverride); if (Optional.IsDefined(SubnetMask) || hasPropertyOverride) { - builder.Append(" subnetMask:"); + builder.Append(" subnetMask: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SubnetMask.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SubnetMask}'''"); } else { - builder.AppendLine($" '{SubnetMask}'"); + builder.AppendLine($"'{SubnetMask}'"); } } } @@ -338,63 +338,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetSubnetResourceId), out propertyOverride); if (Optional.IsDefined(VnetSubnetResourceId) || hasPropertyOverride) { - builder.Append(" vnetSubnetResourceId:"); + builder.Append(" vnetSubnetResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VnetSubnetResourceId.ToString()}'"); + builder.AppendLine($"'{VnetSubnetResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetTrafficTag), out propertyOverride); if (Optional.IsDefined(VnetTrafficTag) || hasPropertyOverride) { - builder.Append(" vnetTrafficTag:"); + builder.Append(" vnetTrafficTag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VnetTrafficTag.Value}"); + builder.AppendLine($"{VnetTrafficTag.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetTrafficTag), out propertyOverride); if (Optional.IsDefined(SubnetTrafficTag) || hasPropertyOverride) { - builder.Append(" subnetTrafficTag:"); + builder.Append(" subnetTrafficTag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SubnetTrafficTag.Value}"); + builder.AppendLine($"{SubnetTrafficTag.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); if (Optional.IsDefined(Action) || hasPropertyOverride) { - builder.Append(" action:"); + builder.Append(" action: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Action.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Action}'''"); } else { - builder.AppendLine($" '{Action}'"); + builder.AppendLine($"'{Action}'"); } } } @@ -402,49 +402,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tag), out propertyOverride); if (Optional.IsDefined(Tag) || hasPropertyOverride) { - builder.Append(" tag:"); + builder.Append(" tag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Tag.Value.ToString()}'"); + builder.AppendLine($"'{Tag.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Priority), out propertyOverride); if (Optional.IsDefined(Priority) || hasPropertyOverride) { - builder.Append(" priority:"); + builder.Append(" priority: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Priority.Value}"); + builder.AppendLine($"{Priority.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -454,23 +454,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Headers.Any() || hasPropertyOverride) { - builder.Append(" headers:"); + builder.Append(" headers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Headers) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item.Value) { if (item0 == null) @@ -499,12 +499,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -525,13 +528,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentifierListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentifierListResult.Serialization.cs index a67079f6e9fd0..a4b5791faa565 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentifierListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentifierListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentityProviders.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentityProviders.Serialization.cs index d3bf7c4f4b581..913e667e03c01 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentityProviders.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceIdentityProviders.Serialization.cs @@ -240,112 +240,112 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureActiveDirectory), out propertyOverride); if (Optional.IsDefined(AzureActiveDirectory) || hasPropertyOverride) { - builder.Append(" azureActiveDirectory:"); + builder.Append(" azureActiveDirectory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureActiveDirectory, options, 2, false); + AppendChildObject(builder, AzureActiveDirectory, options, 2, false, " azureActiveDirectory: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Facebook), out propertyOverride); if (Optional.IsDefined(Facebook) || hasPropertyOverride) { - builder.Append(" facebook:"); + builder.Append(" facebook: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Facebook, options, 2, false); + AppendChildObject(builder, Facebook, options, 2, false, " facebook: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHub), out propertyOverride); if (Optional.IsDefined(GitHub) || hasPropertyOverride) { - builder.Append(" gitHub:"); + builder.Append(" gitHub: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GitHub, options, 2, false); + AppendChildObject(builder, GitHub, options, 2, false, " gitHub: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Google), out propertyOverride); if (Optional.IsDefined(Google) || hasPropertyOverride) { - builder.Append(" google:"); + builder.Append(" google: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Google, options, 2, false); + AppendChildObject(builder, Google, options, 2, false, " google: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LegacyMicrosoftAccount), out propertyOverride); if (Optional.IsDefined(LegacyMicrosoftAccount) || hasPropertyOverride) { - builder.Append(" legacyMicrosoftAccount:"); + builder.Append(" legacyMicrosoftAccount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LegacyMicrosoftAccount, options, 2, false); + AppendChildObject(builder, LegacyMicrosoftAccount, options, 2, false, " legacyMicrosoftAccount: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Twitter), out propertyOverride); if (Optional.IsDefined(Twitter) || hasPropertyOverride) { - builder.Append(" twitter:"); + builder.Append(" twitter: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Twitter, options, 2, false); + AppendChildObject(builder, Twitter, options, 2, false, " twitter: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Apple), out propertyOverride); if (Optional.IsDefined(Apple) || hasPropertyOverride) { - builder.Append(" apple:"); + builder.Append(" apple: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Apple, options, 2, false); + AppendChildObject(builder, Apple, options, 2, false, " apple: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureStaticWebApps), out propertyOverride); if (Optional.IsDefined(AzureStaticWebApps) || hasPropertyOverride) { - builder.Append(" azureStaticWebApps:"); + builder.Append(" azureStaticWebApps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureStaticWebApps, options, 2, false); + AppendChildObject(builder, AzureStaticWebApps, options, 2, false, " azureStaticWebApps: "); } } @@ -354,18 +354,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CustomOpenIdConnectProviders.Any() || hasPropertyOverride) { - builder.Append(" customOpenIdConnectProviders:"); + builder.Append(" customOpenIdConnectProviders: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in CustomOpenIdConnectProviders) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " customOpenIdConnectProviders: "); } builder.AppendLine(" }"); } @@ -376,12 +376,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -402,13 +405,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceNameValuePair.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceNameValuePair.Serialization.cs index d60681c9b84f9..4319583f1fd68 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceNameValuePair.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceNameValuePair.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceOperation.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceOperation.Serialization.cs index 67c7c5009f7ca..92aa5e7ee25f7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceOperation.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceOperation.Serialization.cs @@ -217,21 +217,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -239,21 +239,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -261,14 +261,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } @@ -277,17 +277,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Errors.Any() || hasPropertyOverride) { - builder.Append(" errors:"); + builder.Append(" errors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Errors) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " errors: "); } builder.AppendLine(" ]"); } @@ -297,59 +297,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdTime:"); + builder.Append(" createdTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModifiedOn), out propertyOverride); if (Optional.IsDefined(ModifiedOn) || hasPropertyOverride) { - builder.Append(" modifiedTime:"); + builder.Append(" modifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) { - builder.Append(" expirationTime:"); + builder.Append(" expirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoMasterOperationId), out propertyOverride); if (Optional.IsDefined(GeoMasterOperationId) || hasPropertyOverride) { - builder.Append(" geoMasterOperationId:"); + builder.Append(" geoMasterOperationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{GeoMasterOperationId.Value.ToString()}'"); + builder.AppendLine($"'{GeoMasterOperationId.Value.ToString()}'"); } } @@ -357,12 +357,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -383,13 +386,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanListResult.Serialization.cs index 5525a42d226c4..816f608e86e17 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanPatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanPatch.Serialization.cs index 031372703cd0b..c625cd2021e49 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanPatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanPatch.Serialization.cs @@ -482,21 +482,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -504,21 +504,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -526,28 +526,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -556,21 +556,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerTierName), out propertyOverride); if (Optional.IsDefined(WorkerTierName) || hasPropertyOverride) { - builder.Append(" workerTierName:"); + builder.Append(" workerTierName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WorkerTierName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WorkerTierName}'''"); } else { - builder.AppendLine($" '{WorkerTierName}'"); + builder.AppendLine($"'{WorkerTierName}'"); } } } @@ -578,35 +578,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subscription), out propertyOverride); if (Optional.IsDefined(Subscription) || hasPropertyOverride) { - builder.Append(" subscription:"); + builder.Append(" subscription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subscription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subscription}'''"); } else { - builder.AppendLine($" '{Subscription}'"); + builder.AppendLine($"'{Subscription}'"); } } } @@ -614,49 +614,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNumberOfWorkers), out propertyOverride); if (Optional.IsDefined(MaximumNumberOfWorkers) || hasPropertyOverride) { - builder.Append(" maximumNumberOfWorkers:"); + builder.Append(" maximumNumberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumNumberOfWorkers.Value}"); + builder.AppendLine($"{MaximumNumberOfWorkers.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoRegion), out propertyOverride); if (Optional.IsDefined(GeoRegion) || hasPropertyOverride) { - builder.Append(" geoRegion:"); + builder.Append(" geoRegion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GeoRegion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GeoRegion}'''"); } else { - builder.AppendLine($" '{GeoRegion}'"); + builder.AppendLine($"'{GeoRegion}'"); } } } @@ -664,124 +664,124 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPerSiteScaling), out propertyOverride); if (Optional.IsDefined(IsPerSiteScaling) || hasPropertyOverride) { - builder.Append(" perSiteScaling:"); + builder.Append(" perSiteScaling: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPerSiteScaling.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsElasticScaleEnabled), out propertyOverride); if (Optional.IsDefined(IsElasticScaleEnabled) || hasPropertyOverride) { - builder.Append(" elasticScaleEnabled:"); + builder.Append(" elasticScaleEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsElasticScaleEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumElasticWorkerCount), out propertyOverride); if (Optional.IsDefined(MaximumElasticWorkerCount) || hasPropertyOverride) { - builder.Append(" maximumElasticWorkerCount:"); + builder.Append(" maximumElasticWorkerCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaximumElasticWorkerCount.Value}"); + builder.AppendLine($"{MaximumElasticWorkerCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfSites), out propertyOverride); if (Optional.IsDefined(NumberOfSites) || hasPropertyOverride) { - builder.Append(" numberOfSites:"); + builder.Append(" numberOfSites: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfSites.Value}"); + builder.AppendLine($"{NumberOfSites.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSpot), out propertyOverride); if (Optional.IsDefined(IsSpot) || hasPropertyOverride) { - builder.Append(" isSpot:"); + builder.Append(" isSpot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSpot.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SpotExpirationOn), out propertyOverride); if (Optional.IsDefined(SpotExpirationOn) || hasPropertyOverride) { - builder.Append(" spotExpirationTime:"); + builder.Append(" spotExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SpotExpirationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FreeOfferExpirationOn), out propertyOverride); if (Optional.IsDefined(FreeOfferExpirationOn) || hasPropertyOverride) { - builder.Append(" freeOfferExpirationTime:"); + builder.Append(" freeOfferExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(FreeOfferExpirationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroup), out propertyOverride); if (Optional.IsDefined(ResourceGroup) || hasPropertyOverride) { - builder.Append(" resourceGroup:"); + builder.Append(" resourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroup}'''"); } else { - builder.AppendLine($" '{ResourceGroup}'"); + builder.AppendLine($"'{ResourceGroup}'"); } } } @@ -789,116 +789,116 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReserved), out propertyOverride); if (Optional.IsDefined(IsReserved) || hasPropertyOverride) { - builder.Append(" reserved:"); + builder.Append(" reserved: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReserved.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsXenon), out propertyOverride); if (Optional.IsDefined(IsXenon) || hasPropertyOverride) { - builder.Append(" isXenon:"); + builder.Append(" isXenon: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsXenon.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHyperV), out propertyOverride); if (Optional.IsDefined(IsHyperV) || hasPropertyOverride) { - builder.Append(" hyperV:"); + builder.Append(" hyperV: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHyperV.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetWorkerCount), out propertyOverride); if (Optional.IsDefined(TargetWorkerCount) || hasPropertyOverride) { - builder.Append(" targetWorkerCount:"); + builder.Append(" targetWorkerCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TargetWorkerCount.Value}"); + builder.AppendLine($"{TargetWorkerCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetWorkerSizeId), out propertyOverride); if (Optional.IsDefined(TargetWorkerSizeId) || hasPropertyOverride) { - builder.Append(" targetWorkerSizeId:"); + builder.Append(" targetWorkerSizeId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {TargetWorkerSizeId.Value}"); + builder.AppendLine($"{TargetWorkerSizeId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KubeEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(KubeEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" kubeEnvironmentProfile:"); + builder.Append(" kubeEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, KubeEnvironmentProfile, options, 4, false); + AppendChildObject(builder, KubeEnvironmentProfile, options, 4, false, " kubeEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) { - builder.Append(" zoneRedundant:"); + builder.Append(" zoneRedundant: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -907,12 +907,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -933,13 +936,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanResourceListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanResourceListResult.Serialization.cs index 12769c9c6b3a8..119c76735e32d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanResourceListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePlanResourceListResult.Serialization.cs @@ -125,14 +125,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { if (item == null) @@ -158,21 +158,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfo.Serialization.cs index b1b72c21e0bf5..37038d6c88e2a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfo.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceType.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Capacity, options, 2, false); + AppendChildObject(builder, Capacity, options, 2, false, " capacity: "); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfoListResult.Serialization.cs index 825e1b59734ca..4c15cfcd9001b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePoolSkuInfoListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceData.Serialization.cs index 2fd43f6cbaaf4..962e10149d92a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceData.Serialization.cs @@ -150,21 +150,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -172,42 +172,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceProperties.Serialization.cs index e07154a0f4c58..5b34cf8d6a5f4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServicePrivateLinkResourceProperties.Serialization.cs @@ -155,21 +155,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); if (Optional.IsDefined(GroupId) || hasPropertyOverride) { - builder.Append(" groupId:"); + builder.Append(" groupId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GroupId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GroupId}'''"); } else { - builder.AppendLine($" '{GroupId}'"); + builder.AppendLine($"'{GroupId}'"); } } } @@ -179,14 +179,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredMembers.Any() || hasPropertyOverride) { - builder.Append(" requiredMembers:"); + builder.Append(" requiredMembers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredMembers) { if (item == null) @@ -214,14 +214,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RequiredZoneNames.Any() || hasPropertyOverride) { - builder.Append(" requiredZoneNames:"); + builder.Append(" requiredZoneNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RequiredZoneNames) { if (item == null) @@ -248,12 +248,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -274,13 +277,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendation.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendation.Serialization.cs index c98606c5eb500..52a4bd5fc6b90 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendation.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendation.Serialization.cs @@ -506,21 +506,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -528,21 +528,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -550,28 +550,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -580,78 +580,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" creationTime:"); + builder.Append(" creationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationId), out propertyOverride); if (Optional.IsDefined(RecommendationId) || hasPropertyOverride) { - builder.Append(" recommendationId:"); + builder.Append(" recommendationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RecommendationId.Value.ToString()}'"); + builder.AppendLine($"'{RecommendationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); if (Optional.IsDefined(ResourceId) || hasPropertyOverride) { - builder.Append(" resourceId:"); + builder.Append(" resourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceId.ToString()}'"); + builder.AppendLine($"'{ResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceScope), out propertyOverride); if (Optional.IsDefined(ResourceScope) || hasPropertyOverride) { - builder.Append(" resourceScope:"); + builder.Append(" resourceScope: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceScope.Value.ToString()}'"); + builder.AppendLine($"'{ResourceScope.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuleName), out propertyOverride); if (Optional.IsDefined(RuleName) || hasPropertyOverride) { - builder.Append(" ruleName:"); + builder.Append(" ruleName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuleName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuleName}'''"); } else { - builder.AppendLine($" '{RuleName}'"); + builder.AppendLine($"'{RuleName}'"); } } } @@ -659,21 +659,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -681,21 +681,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -703,28 +703,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.Value.ToSerialString()}'"); + builder.AppendLine($"'{Level.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Channels), out propertyOverride); if (Optional.IsDefined(Channels) || hasPropertyOverride) { - builder.Append(" channels:"); + builder.Append(" channels: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Channels.Value.ToSerialString()}'"); + builder.AppendLine($"'{Channels.Value.ToSerialString()}'"); } } @@ -733,14 +733,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CategoryTags.Any() || hasPropertyOverride) { - builder.Append(" categoryTags:"); + builder.Append(" categoryTags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CategoryTags) { if (item == null) @@ -766,21 +766,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionName), out propertyOverride); if (Optional.IsDefined(ActionName) || hasPropertyOverride) { - builder.Append(" actionName:"); + builder.Append(" actionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionName}'''"); } else { - builder.AppendLine($" '{ActionName}'"); + builder.AppendLine($"'{ActionName}'"); } } } @@ -788,14 +788,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); if (Optional.IsDefined(Enabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Enabled.Value}"); + builder.AppendLine($"{Enabled.Value}"); } } @@ -804,14 +804,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (States.Any() || hasPropertyOverride) { - builder.Append(" states:"); + builder.Append(" states: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in States) { if (item == null) @@ -837,125 +837,125 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextNotificationOn), out propertyOverride); if (Optional.IsDefined(NextNotificationOn) || hasPropertyOverride) { - builder.Append(" nextNotificationTime:"); + builder.Append(" nextNotificationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextNotificationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotificationExpirationOn), out propertyOverride); if (Optional.IsDefined(NotificationExpirationOn) || hasPropertyOverride) { - builder.Append(" notificationExpirationTime:"); + builder.Append(" notificationExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotificationExpirationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotifiedOn), out propertyOverride); if (Optional.IsDefined(NotifiedOn) || hasPropertyOverride) { - builder.Append(" notifiedTime:"); + builder.Append(" notifiedTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NotifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Score), out propertyOverride); if (Optional.IsDefined(Score) || hasPropertyOverride) { - builder.Append(" score:"); + builder.Append(" score: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Score.Value.ToString()}'"); + builder.AppendLine($"'{Score.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDynamic), out propertyOverride); if (Optional.IsDefined(IsDynamic) || hasPropertyOverride) { - builder.Append(" isDynamic:"); + builder.Append(" isDynamic: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDynamic.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtensionName), out propertyOverride); if (Optional.IsDefined(ExtensionName) || hasPropertyOverride) { - builder.Append(" extensionName:"); + builder.Append(" extensionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ExtensionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ExtensionName}'''"); } else { - builder.AppendLine($" '{ExtensionName}'"); + builder.AppendLine($"'{ExtensionName}'"); } } } @@ -963,21 +963,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BladeName), out propertyOverride); if (Optional.IsDefined(BladeName) || hasPropertyOverride) { - builder.Append(" bladeName:"); + builder.Append(" bladeName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BladeName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BladeName}'''"); } else { - builder.AppendLine($" '{BladeName}'"); + builder.AppendLine($"'{BladeName}'"); } } } @@ -985,21 +985,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForwardLink), out propertyOverride); if (Optional.IsDefined(ForwardLink) || hasPropertyOverride) { - builder.Append(" forwardLink:"); + builder.Append(" forwardLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ForwardLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ForwardLink}'''"); } else { - builder.AppendLine($" '{ForwardLink}'"); + builder.AppendLine($"'{ForwardLink}'"); } } } @@ -1009,12 +1009,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1035,13 +1038,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendationListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendationListResult.Serialization.cs index 9d495ef51ae19..75bc70de3d30e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendationListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceRecommendationListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapability.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapability.Serialization.cs index 0f183ea25c8df..f2b7682f4a465 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapability.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapability.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Reason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Reason}'''"); } else { - builder.AppendLine($" '{Reason}'"); + builder.AppendLine($"'{Reason}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapacity.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapacity.Serialization.cs index e62ac50333ec7..c01085bcd8243 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapacity.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuCapacity.Serialization.cs @@ -164,77 +164,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Minimum), out propertyOverride); if (Optional.IsDefined(Minimum) || hasPropertyOverride) { - builder.Append(" minimum:"); + builder.Append(" minimum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Minimum.Value}"); + builder.AppendLine($"{Minimum.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Maximum), out propertyOverride); if (Optional.IsDefined(Maximum) || hasPropertyOverride) { - builder.Append(" maximum:"); + builder.Append(" maximum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Maximum.Value}"); + builder.AppendLine($"{Maximum.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ElasticMaximum), out propertyOverride); if (Optional.IsDefined(ElasticMaximum) || hasPropertyOverride) { - builder.Append(" elasticMaximum:"); + builder.Append(" elasticMaximum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ElasticMaximum.Value}"); + builder.AppendLine($"{ElasticMaximum.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Default), out propertyOverride); if (Optional.IsDefined(Default) || hasPropertyOverride) { - builder.Append(" default:"); + builder.Append(" default: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Default.Value}"); + builder.AppendLine($"{Default.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScaleType), out propertyOverride); if (Optional.IsDefined(ScaleType) || hasPropertyOverride) { - builder.Append(" scaleType:"); + builder.Append(" scaleType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScaleType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScaleType}'''"); } else { - builder.AppendLine($" '{ScaleType}'"); + builder.AppendLine($"'{ScaleType}'"); } } } @@ -243,12 +243,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -269,13 +272,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuDescription.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuDescription.Serialization.cs index e19def8b59488..15b2a84326a68 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuDescription.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuDescription.Serialization.cs @@ -218,21 +218,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -240,21 +240,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -262,21 +262,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -306,28 +306,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Capacity.Value}"); + builder.AppendLine($"{Capacity.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkuCapacity), out propertyOverride); if (Optional.IsDefined(SkuCapacity) || hasPropertyOverride) { - builder.Append(" skuCapacity:"); + builder.Append(" skuCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SkuCapacity, options, 2, false); + AppendChildObject(builder, SkuCapacity, options, 2, false, " skuCapacity: "); } } @@ -336,14 +336,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Locations.Any() || hasPropertyOverride) { - builder.Append(" locations:"); + builder.Append(" locations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Locations) { builder.AppendLine($" '{item.ToString()}'"); @@ -358,17 +358,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Capabilities.Any() || hasPropertyOverride) { - builder.Append(" capabilities:"); + builder.Append(" capabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Capabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " capabilities: "); } builder.AppendLine(" ]"); } @@ -379,12 +379,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -405,13 +408,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuResult.Serialization.cs index 1370116dac42c..82a1aa5da2106 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSkuResult.Serialization.cs @@ -134,14 +134,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" resourceType:"); + builder.Append(" resourceType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceType.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } @@ -150,17 +150,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Skus.Any() || hasPropertyOverride) { - builder.Append(" skus:"); + builder.Append(" skus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Skus) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " skus: "); } builder.AppendLine(" ]"); } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSourceControlListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSourceControlListResult.Serialization.cs index 22853fb9fc71a..9749e81a95072 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSourceControlListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceSourceControlListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsProvider.Serialization.cs index 68d9b331345e9..1801abe9e2101 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsProvider.Serialization.cs @@ -123,29 +123,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsRegistration.Serialization.cs index 356a2f6a9207e..13f7cea08aa51 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStaticWebAppsRegistration.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStatusInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStatusInfo.Serialization.cs index c273d6d9d1593..77538b6268421 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStatusInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStatusInfo.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusId), out propertyOverride); if (Optional.IsDefined(StatusId) || hasPropertyOverride) { - builder.Append(" statusId:"); + builder.Append(" statusId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StatusId.Value.ToSerialString()}'"); + builder.AppendLine($"'{StatusId.Value.ToSerialString()}'"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStorageAccessInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStorageAccessInfo.Serialization.cs index 3f69c67c3c69b..76aedfd463f67 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStorageAccessInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceStorageAccessInfo.Serialization.cs @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccountName), out propertyOverride); if (Optional.IsDefined(AccountName) || hasPropertyOverride) { - builder.Append(" accountName:"); + builder.Append(" accountName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AccountName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AccountName}'''"); } else { - builder.AppendLine($" '{AccountName}'"); + builder.AppendLine($"'{AccountName}'"); } } } @@ -189,21 +189,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShareName), out propertyOverride); if (Optional.IsDefined(ShareName) || hasPropertyOverride) { - builder.Append(" shareName:"); + builder.Append(" shareName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ShareName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ShareName}'''"); } else { - builder.AppendLine($" '{ShareName}'"); + builder.AppendLine($"'{ShareName}'"); } } } @@ -211,21 +211,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessKey), out propertyOverride); if (Optional.IsDefined(AccessKey) || hasPropertyOverride) { - builder.Append(" accessKey:"); + builder.Append(" accessKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AccessKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AccessKey}'''"); } else { - builder.AppendLine($" '{AccessKey}'"); + builder.AppendLine($"'{AccessKey}'"); } } } @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MountPath), out propertyOverride); if (Optional.IsDefined(MountPath) || hasPropertyOverride) { - builder.Append(" mountPath:"); + builder.Append(" mountPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MountPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MountPath}'''"); } else { - builder.AppendLine($" '{MountPath}'"); + builder.AppendLine($"'{MountPath}'"); } } } @@ -255,14 +255,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } @@ -270,12 +270,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -296,13 +299,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTableStorageApplicationLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTableStorageApplicationLogsConfig.Serialization.cs index 17830112d0194..e940476fcf946 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTableStorageApplicationLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTableStorageApplicationLogsConfig.Serialization.cs @@ -116,35 +116,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.Value.ToSerialString()}'"); + builder.AppendLine($"'{Level.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasUriString), out propertyOverride); if (Optional.IsDefined(SasUriString) || hasPropertyOverride) { - builder.Append(" sasUrl:"); + builder.Append(" sasUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SasUriString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SasUriString}'''"); } else { - builder.AppendLine($" '{SasUriString}'"); + builder.AppendLine($"'{SasUriString}'"); } } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTokenStore.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTokenStore.Serialization.cs index 6589e55385fb3..37eab38dc6b7b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTokenStore.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTokenStore.Serialization.cs @@ -153,57 +153,57 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenRefreshExtensionHours), out propertyOverride); if (Optional.IsDefined(TokenRefreshExtensionHours) || hasPropertyOverride) { - builder.Append(" tokenRefreshExtensionHours:"); + builder.Append(" tokenRefreshExtensionHours: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TokenRefreshExtensionHours.Value.ToString()}'"); + builder.AppendLine($"'{TokenRefreshExtensionHours.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileSystem), out propertyOverride); if (Optional.IsDefined(FileSystem) || hasPropertyOverride) { - builder.Append(" fileSystem:"); + builder.Append(" fileSystem: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, FileSystem, options, 2, false); + AppendChildObject(builder, FileSystem, options, 2, false, " fileSystem: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureBlobStorage), out propertyOverride); if (Optional.IsDefined(AzureBlobStorage) || hasPropertyOverride) { - builder.Append(" azureBlobStorage:"); + builder.Append(" azureBlobStorage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureBlobStorage, options, 2, false); + AppendChildObject(builder, AzureBlobStorage, options, 2, false, " azureBlobStorage: "); } } @@ -211,12 +211,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -237,13 +240,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTwitterProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTwitterProvider.Serialization.cs index 24fd61f215433..f8f9ed2e94a2f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTwitterProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceTwitterProvider.Serialization.cs @@ -123,29 +123,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -153,12 +153,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -179,13 +182,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsage.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsage.Serialization.cs index c0796e8bf74a9..841ed22f1ef92 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsage.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsage.Serialization.cs @@ -272,21 +272,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -294,21 +294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -316,28 +316,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -346,21 +346,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -368,21 +368,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceName), out propertyOverride); if (Optional.IsDefined(ResourceName) || hasPropertyOverride) { - builder.Append(" resourceName:"); + builder.Append(" resourceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceName}'''"); } else { - builder.AppendLine($" '{ResourceName}'"); + builder.AppendLine($"'{ResourceName}'"); } } } @@ -390,21 +390,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -412,78 +412,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.Value.ToString()}'"); + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextResetOn), out propertyOverride); if (Optional.IsDefined(NextResetOn) || hasPropertyOverride) { - builder.Append(" nextResetTime:"); + builder.Append(" nextResetTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextResetOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ComputeMode), out propertyOverride); if (Optional.IsDefined(ComputeMode) || hasPropertyOverride) { - builder.Append(" computeMode:"); + builder.Append(" computeMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ComputeMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ComputeMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteMode), out propertyOverride); if (Optional.IsDefined(SiteMode) || hasPropertyOverride) { - builder.Append(" siteMode:"); + builder.Append(" siteMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteMode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteMode}'''"); } else { - builder.AppendLine($" '{SiteMode}'"); + builder.AppendLine($"'{SiteMode}'"); } } } @@ -493,12 +493,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -519,13 +522,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsageListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsageListResult.Serialization.cs index f01dcd9ca3486..67dc32fb2f15d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsageListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceUsageListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceValidateResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceValidateResult.Serialization.cs index 62fd83eabcffb..2f0d7ca9c18ea 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceValidateResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceValidateResult.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProfile.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProfile.Serialization.cs index 194cd45effe80..4812f2dc8814f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProfile.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProfile.Serialization.cs @@ -138,21 +138,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -160,35 +160,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subnet), out propertyOverride); if (Optional.IsDefined(Subnet) || hasPropertyOverride) { - builder.Append(" subnet:"); + builder.Append(" subnet: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Subnet.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Subnet}'''"); } else { - builder.AppendLine($" '{Subnet}'"); + builder.AppendLine($"'{Subnet}'"); } } } @@ -197,12 +197,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -223,13 +226,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProperties.Serialization.cs index af56a5acc75d9..2354585b9f9bc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkProperties.Serialization.cs @@ -197,35 +197,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetResourceId), out propertyOverride); if (Optional.IsDefined(VnetResourceId) || hasPropertyOverride) { - builder.Append(" vnetResourceId:"); + builder.Append(" vnetResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VnetResourceId.ToString()}'"); + builder.AppendLine($"'{VnetResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertThumbprintString), out propertyOverride); if (Optional.IsDefined(CertThumbprintString) || hasPropertyOverride) { - builder.Append(" certThumbprint:"); + builder.Append(" certThumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertThumbprintString}'''"); } else { - builder.AppendLine($" '{CertThumbprintString}'"); + builder.AppendLine($"'{CertThumbprintString}'"); } } } @@ -233,21 +233,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertBlob), out propertyOverride); if (Optional.IsDefined(CertBlob) || hasPropertyOverride) { - builder.Append(" certBlob:"); + builder.Append(" certBlob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CertBlob.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CertBlob}'''"); } else { - builder.AppendLine($" '{CertBlob}'"); + builder.AppendLine($"'{CertBlob}'"); } } } @@ -257,17 +257,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Routes.Any() || hasPropertyOverride) { - builder.Append(" routes:"); + builder.Append(" routes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Routes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " routes: "); } builder.AppendLine(" ]"); } @@ -277,36 +277,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsResyncRequired), out propertyOverride); if (Optional.IsDefined(IsResyncRequired) || hasPropertyOverride) { - builder.Append(" resyncRequired:"); + builder.Append(" resyncRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsResyncRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsServers), out propertyOverride); if (Optional.IsDefined(DnsServers) || hasPropertyOverride) { - builder.Append(" dnsServers:"); + builder.Append(" dnsServers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DnsServers.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DnsServers}'''"); } else { - builder.AppendLine($" '{DnsServers}'"); + builder.AppendLine($"'{DnsServers}'"); } } } @@ -314,15 +314,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSwift), out propertyOverride); if (Optional.IsDefined(IsSwift) || hasPropertyOverride) { - builder.Append(" isSwift:"); + builder.Append(" isSwift: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSwift.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -330,12 +330,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -356,13 +359,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkRoute.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkRoute.Serialization.cs index 9c9da17034fe6..b875d8f2cbe2a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkRoute.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkRoute.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -249,28 +249,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartAddress), out propertyOverride); if (Optional.IsDefined(StartAddress) || hasPropertyOverride) { - builder.Append(" startAddress:"); + builder.Append(" startAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartAddress}'''"); } else { - builder.AppendLine($" '{StartAddress}'"); + builder.AppendLine($"'{StartAddress}'"); } } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndAddress), out propertyOverride); if (Optional.IsDefined(EndAddress) || hasPropertyOverride) { - builder.Append(" endAddress:"); + builder.Append(" endAddress: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EndAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EndAddress}'''"); } else { - builder.AppendLine($" '{EndAddress}'"); + builder.AppendLine($"'{EndAddress}'"); } } } @@ -323,14 +323,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RouteType), out propertyOverride); if (Optional.IsDefined(RouteType) || hasPropertyOverride) { - builder.Append(" routeType:"); + builder.Append(" routeType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RouteType.Value.ToString()}'"); + builder.AppendLine($"'{RouteType.Value.ToString()}'"); } } @@ -339,12 +339,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -365,13 +368,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkValidationContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkValidationContent.Serialization.cs index a43af36b2f344..3832e34f8ca21 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkValidationContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceVirtualNetworkValidationContent.Serialization.cs @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -260,28 +260,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -290,21 +290,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetResourceGroup), out propertyOverride); if (Optional.IsDefined(VnetResourceGroup) || hasPropertyOverride) { - builder.Append(" vnetResourceGroup:"); + builder.Append(" vnetResourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetResourceGroup}'''"); } else { - builder.AppendLine($" '{VnetResourceGroup}'"); + builder.AppendLine($"'{VnetResourceGroup}'"); } } } @@ -312,21 +312,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetName), out propertyOverride); if (Optional.IsDefined(VnetName) || hasPropertyOverride) { - builder.Append(" vnetName:"); + builder.Append(" vnetName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetName}'''"); } else { - builder.AppendLine($" '{VnetName}'"); + builder.AppendLine($"'{VnetName}'"); } } } @@ -334,21 +334,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetSubnetName), out propertyOverride); if (Optional.IsDefined(VnetSubnetName) || hasPropertyOverride) { - builder.Append(" vnetSubnetName:"); + builder.Append(" vnetSubnetName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetSubnetName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetSubnetName}'''"); } else { - builder.AppendLine($" '{VnetSubnetName}'"); + builder.AppendLine($"'{VnetSubnetName}'"); } } } @@ -356,14 +356,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetResourceId), out propertyOverride); if (Optional.IsDefined(SubnetResourceId) || hasPropertyOverride) { - builder.Append(" subnetResourceId:"); + builder.Append(" subnetResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetResourceId.ToString()}'"); + builder.AppendLine($"'{SubnetResourceId.ToString()}'"); } } @@ -372,12 +372,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -398,13 +401,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceWorkerPoolListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceWorkerPoolListResult.Serialization.cs index 843c7541e87ed..c9817c7d9d42b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceWorkerPoolListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppServiceWorkerPoolListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshot.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshot.Serialization.cs index bcfbb029ac173..26d97296f329e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshot.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshot.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Time), out propertyOverride); if (Optional.IsDefined(Time) || hasPropertyOverride) { - builder.Append(" time:"); + builder.Append(" time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Time.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Time}'''"); } else { - builder.AppendLine($" '{Time}'"); + builder.AppendLine($"'{Time}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshotListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshotListResult.Serialization.cs index 53e0fa41554b5..e1e0e6dccd6eb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshotListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AppSnapshotListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationLogsConfig.Serialization.cs index 3e92babff59c7..1783d1428e865 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationLogsConfig.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileSystem), out propertyOverride); if (Optional.IsDefined(FileSystem) || hasPropertyOverride) { - builder.Append(" fileSystem:"); + builder.Append(" fileSystem: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, FileSystem, options, 2, false); + AppendChildObject(builder, FileSystem, options, 2, false, " fileSystem: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureTableStorage), out propertyOverride); if (Optional.IsDefined(AzureTableStorage) || hasPropertyOverride) { - builder.Append(" azureTableStorage:"); + builder.Append(" azureTableStorage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureTableStorage, options, 2, false); + AppendChildObject(builder, AzureTableStorage, options, 2, false, " azureTableStorage: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureBlobStorage), out propertyOverride); if (Optional.IsDefined(AzureBlobStorage) || hasPropertyOverride) { - builder.Append(" azureBlobStorage:"); + builder.Append(" azureBlobStorage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AzureBlobStorage, options, 2, false); + AppendChildObject(builder, AzureBlobStorage, options, 2, false, " azureBlobStorage: "); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStack.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStack.Serialization.cs index d373db852fb20..78d2668799f2d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStack.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStack.Serialization.cs @@ -202,21 +202,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -224,21 +224,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Display), out propertyOverride); if (Optional.IsDefined(Display) || hasPropertyOverride) { - builder.Append(" display:"); + builder.Append(" display: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Display.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Display}'''"); } else { - builder.AppendLine($" '{Display}'"); + builder.AppendLine($"'{Display}'"); } } } @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Dependency), out propertyOverride); if (Optional.IsDefined(Dependency) || hasPropertyOverride) { - builder.Append(" dependency:"); + builder.Append(" dependency: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Dependency.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Dependency}'''"); } else { - builder.AppendLine($" '{Dependency}'"); + builder.AppendLine($"'{Dependency}'"); } } } @@ -270,17 +270,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MajorVersions.Any() || hasPropertyOverride) { - builder.Append(" majorVersions:"); + builder.Append(" majorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MajorVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " majorVersions: "); } builder.AppendLine(" ]"); } @@ -292,17 +292,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Frameworks.Any() || hasPropertyOverride) { - builder.Append(" frameworks:"); + builder.Append(" frameworks: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Frameworks) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " frameworks: "); } builder.AppendLine(" ]"); } @@ -314,17 +314,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IsDeprecated.Any() || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IsDeprecated) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " isDeprecated: "); } builder.AppendLine(" ]"); } @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackListResult.Serialization.cs index 3a9a747d3767c..88bc704c8f94d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackResource.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackResource.Serialization.cs index 90a958756bff1..370592e4254cb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackResource.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ApplicationStackResource.Serialization.cs @@ -277,21 +277,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -299,21 +299,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -321,28 +321,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -351,21 +351,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StackName), out propertyOverride); if (Optional.IsDefined(StackName) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StackName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StackName}'''"); } else { - builder.AppendLine($" '{StackName}'"); + builder.AppendLine($"'{StackName}'"); } } } @@ -373,21 +373,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Display), out propertyOverride); if (Optional.IsDefined(Display) || hasPropertyOverride) { - builder.Append(" display:"); + builder.Append(" display: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Display.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Display}'''"); } else { - builder.AppendLine($" '{Display}'"); + builder.AppendLine($"'{Display}'"); } } } @@ -395,21 +395,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Dependency), out propertyOverride); if (Optional.IsDefined(Dependency) || hasPropertyOverride) { - builder.Append(" dependency:"); + builder.Append(" dependency: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Dependency.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Dependency}'''"); } else { - builder.AppendLine($" '{Dependency}'"); + builder.AppendLine($"'{Dependency}'"); } } } @@ -419,17 +419,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MajorVersions.Any() || hasPropertyOverride) { - builder.Append(" majorVersions:"); + builder.Append(" majorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MajorVersions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " majorVersions: "); } builder.AppendLine(" ]"); } @@ -441,17 +441,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Frameworks.Any() || hasPropertyOverride) { - builder.Append(" frameworks:"); + builder.Append(" frameworks: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Frameworks) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " frameworks: "); } builder.AppendLine(" ]"); } @@ -463,17 +463,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IsDeprecated.Any() || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IsDeprecated) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " isDeprecated: "); } builder.AppendLine(" ]"); } @@ -485,12 +485,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -511,13 +514,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ArcConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ArcConfiguration.Serialization.cs index 5e0d2755053c2..b9a08526ea354 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ArcConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ArcConfiguration.Serialization.cs @@ -178,35 +178,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArtifactsStorageType), out propertyOverride); if (Optional.IsDefined(ArtifactsStorageType) || hasPropertyOverride) { - builder.Append(" artifactsStorageType:"); + builder.Append(" artifactsStorageType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ArtifactsStorageType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ArtifactsStorageType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArtifactStorageClassName), out propertyOverride); if (Optional.IsDefined(ArtifactStorageClassName) || hasPropertyOverride) { - builder.Append(" artifactStorageClassName:"); + builder.Append(" artifactStorageClassName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ArtifactStorageClassName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ArtifactStorageClassName}'''"); } else { - builder.AppendLine($" '{ArtifactStorageClassName}'"); + builder.AppendLine($"'{ArtifactStorageClassName}'"); } } } @@ -214,21 +214,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArtifactStorageMountPath), out propertyOverride); if (Optional.IsDefined(ArtifactStorageMountPath) || hasPropertyOverride) { - builder.Append(" artifactStorageMountPath:"); + builder.Append(" artifactStorageMountPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ArtifactStorageMountPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ArtifactStorageMountPath}'''"); } else { - builder.AppendLine($" '{ArtifactStorageMountPath}'"); + builder.AppendLine($"'{ArtifactStorageMountPath}'"); } } } @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArtifactStorageNodeName), out propertyOverride); if (Optional.IsDefined(ArtifactStorageNodeName) || hasPropertyOverride) { - builder.Append(" artifactStorageNodeName:"); + builder.Append(" artifactStorageNodeName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ArtifactStorageNodeName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ArtifactStorageNodeName}'''"); } else { - builder.AppendLine($" '{ArtifactStorageNodeName}'"); + builder.AppendLine($"'{ArtifactStorageNodeName}'"); } } } @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArtifactStorageAccessMode), out propertyOverride); if (Optional.IsDefined(ArtifactStorageAccessMode) || hasPropertyOverride) { - builder.Append(" artifactStorageAccessMode:"); + builder.Append(" artifactStorageAccessMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ArtifactStorageAccessMode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ArtifactStorageAccessMode}'''"); } else { - builder.AppendLine($" '{ArtifactStorageAccessMode}'"); + builder.AppendLine($"'{ArtifactStorageAccessMode}'"); } } } @@ -280,35 +280,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrontEndServiceConfiguration), out propertyOverride); if (Optional.IsDefined(FrontEndServiceConfiguration) || hasPropertyOverride) { - builder.Append(" frontEndServiceConfiguration:"); + builder.Append(" frontEndServiceConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, FrontEndServiceConfiguration, options, 2, false); + AppendChildObject(builder, FrontEndServiceConfiguration, options, 2, false, " frontEndServiceConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KubeConfig), out propertyOverride); if (Optional.IsDefined(KubeConfig) || hasPropertyOverride) { - builder.Append(" kubeConfig:"); + builder.Append(" kubeConfig: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KubeConfig.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KubeConfig}'''"); } else { - builder.AppendLine($" '{KubeConfig}'"); + builder.AppendLine($"'{KubeConfig}'"); } } } @@ -317,12 +317,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -343,13 +346,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AuthPlatform.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AuthPlatform.Serialization.cs index 88e4eb6433888..8f9751d9969c5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AuthPlatform.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AuthPlatform.Serialization.cs @@ -130,36 +130,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConfigFilePath), out propertyOverride); if (Optional.IsDefined(ConfigFilePath) || hasPropertyOverride) { - builder.Append(" configFilePath:"); + builder.Append(" configFilePath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConfigFilePath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConfigFilePath}'''"); } else { - builder.AppendLine($" '{ConfigFilePath}'"); + builder.AppendLine($"'{ConfigFilePath}'"); } } } @@ -190,12 +190,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -216,13 +219,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealActions.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealActions.Serialization.cs index 3a27c5ff07c52..c0a1547b0afa8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealActions.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealActions.Serialization.cs @@ -134,49 +134,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionType), out propertyOverride); if (Optional.IsDefined(ActionType) || hasPropertyOverride) { - builder.Append(" actionType:"); + builder.Append(" actionType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActionType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomAction), out propertyOverride); if (Optional.IsDefined(CustomAction) || hasPropertyOverride) { - builder.Append(" customAction:"); + builder.Append(" customAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CustomAction, options, 2, false); + AppendChildObject(builder, CustomAction, options, 2, false, " customAction: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinProcessExecutionTime), out propertyOverride); if (Optional.IsDefined(MinProcessExecutionTime) || hasPropertyOverride) { - builder.Append(" minProcessExecutionTime:"); + builder.Append(" minProcessExecutionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MinProcessExecutionTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MinProcessExecutionTime}'''"); } else { - builder.AppendLine($" '{MinProcessExecutionTime}'"); + builder.AppendLine($"'{MinProcessExecutionTime}'"); } } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealCustomAction.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealCustomAction.Serialization.cs index b9a389903a5b5..6353617aa9839 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealCustomAction.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealCustomAction.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Exe), out propertyOverride); if (Optional.IsDefined(Exe) || hasPropertyOverride) { - builder.Append(" exe:"); + builder.Append(" exe: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Exe.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Exe}'''"); } else { - builder.AppendLine($" '{Exe}'"); + builder.AppendLine($"'{Exe}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parameters), out propertyOverride); if (Optional.IsDefined(Parameters) || hasPropertyOverride) { - builder.Append(" parameters:"); + builder.Append(" parameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Parameters.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Parameters}'''"); } else { - builder.AppendLine($" '{Parameters}'"); + builder.AppendLine($"'{Parameters}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealRules.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealRules.Serialization.cs index 990d43b7db0ac..3eea3480b539c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealRules.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealRules.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Triggers), out propertyOverride); if (Optional.IsDefined(Triggers) || hasPropertyOverride) { - builder.Append(" triggers:"); + builder.Append(" triggers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Triggers, options, 2, false); + AppendChildObject(builder, Triggers, options, 2, false, " triggers: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Actions), out propertyOverride); if (Optional.IsDefined(Actions) || hasPropertyOverride) { - builder.Append(" actions:"); + builder.Append(" actions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Actions, options, 2, false); + AppendChildObject(builder, Actions, options, 2, false, " actions: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealTriggers.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealTriggers.Serialization.cs index 165699f5b4232..9065827203373 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealTriggers.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AutoHealTriggers.Serialization.cs @@ -214,28 +214,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Requests), out propertyOverride); if (Optional.IsDefined(Requests) || hasPropertyOverride) { - builder.Append(" requests:"); + builder.Append(" requests: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Requests, options, 2, false); + AppendChildObject(builder, Requests, options, 2, false, " requests: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateBytesInKB), out propertyOverride); if (Optional.IsDefined(PrivateBytesInKB) || hasPropertyOverride) { - builder.Append(" privateBytesInKB:"); + builder.Append(" privateBytesInKB: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PrivateBytesInKB.Value}"); + builder.AppendLine($"{PrivateBytesInKB.Value}"); } } @@ -244,17 +244,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (StatusCodes.Any() || hasPropertyOverride) { - builder.Append(" statusCodes:"); + builder.Append(" statusCodes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in StatusCodes) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " statusCodes: "); } builder.AppendLine(" ]"); } @@ -264,14 +264,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SlowRequests), out propertyOverride); if (Optional.IsDefined(SlowRequests) || hasPropertyOverride) { - builder.Append(" slowRequests:"); + builder.Append(" slowRequests: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SlowRequests, options, 2, false); + AppendChildObject(builder, SlowRequests, options, 2, false, " slowRequests: "); } } @@ -280,17 +280,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SlowRequestsWithPath.Any() || hasPropertyOverride) { - builder.Append(" slowRequestsWithPath:"); + builder.Append(" slowRequestsWithPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SlowRequestsWithPath) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " slowRequestsWithPath: "); } builder.AppendLine(" ]"); } @@ -302,17 +302,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (StatusCodesRange.Any() || hasPropertyOverride) { - builder.Append(" statusCodesRange:"); + builder.Append(" statusCodesRange: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in StatusCodesRange) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " statusCodesRange: "); } builder.AppendLine(" ]"); } @@ -323,12 +323,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -349,13 +352,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AzureStoragePropertyDictionary.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AzureStoragePropertyDictionary.Serialization.cs index 458f9c961ef2a..d2361e6781061 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AzureStoragePropertyDictionary.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/AzureStoragePropertyDictionary.Serialization.cs @@ -180,21 +180,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -204,18 +204,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Properties) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " properties: "); } builder.AppendLine(" }"); } @@ -225,21 +225,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -247,28 +247,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -276,12 +276,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -302,13 +305,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderAction.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderAction.Serialization.cs index 6d07c0495e0c3..623c9d98dbfb8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderAction.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderAction.Serialization.cs @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,29 +272,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionType), out propertyOverride); if (Optional.IsDefined(ActionType) || hasPropertyOverride) { - builder.Append(" actionType:"); + builder.Append(" actionType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ActionType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActionType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdAt:"); + builder.Append(" createdAt: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderContact.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderContact.Serialization.cs index 268a1b58915a9..78e6cba10ea11 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderContact.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CertificateOrderContact.Serialization.cs @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Email), out propertyOverride); if (Optional.IsDefined(Email) || hasPropertyOverride) { - builder.Append(" email:"); + builder.Append(" email: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Email.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Email}'''"); } else { - builder.AppendLine($" '{Email}'"); + builder.AppendLine($"'{Email}'"); } } } @@ -159,21 +159,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameFirst), out propertyOverride); if (Optional.IsDefined(NameFirst) || hasPropertyOverride) { - builder.Append(" nameFirst:"); + builder.Append(" nameFirst: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameFirst.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameFirst}'''"); } else { - builder.AppendLine($" '{NameFirst}'"); + builder.AppendLine($"'{NameFirst}'"); } } } @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameLast), out propertyOverride); if (Optional.IsDefined(NameLast) || hasPropertyOverride) { - builder.Append(" nameLast:"); + builder.Append(" nameLast: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameLast.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameLast}'''"); } else { - builder.AppendLine($" '{NameLast}'"); + builder.AppendLine($"'{NameLast}'"); } } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Phone), out propertyOverride); if (Optional.IsDefined(Phone) || hasPropertyOverride) { - builder.Append(" phone:"); + builder.Append(" phone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Phone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Phone}'''"); } else { - builder.AppendLine($" '{Phone}'"); + builder.AppendLine($"'{Phone}'"); } } } @@ -226,12 +226,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -252,13 +255,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ClientRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ClientRegistration.Serialization.cs index befe0ef54f6d5..2485396014e51 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ClientRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ClientRegistration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" clientSecretSettingName:"); + builder.Append(" clientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{ClientSecretSettingName}'"); + builder.AppendLine($"'{ClientSecretSettingName}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CloningInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CloningInfo.Serialization.cs index 948b6fb4c96b1..83dabc2f9a621 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CloningInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CloningInfo.Serialization.cs @@ -255,108 +255,108 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CorrelationId), out propertyOverride); if (Optional.IsDefined(CorrelationId) || hasPropertyOverride) { - builder.Append(" correlationId:"); + builder.Append(" correlationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CorrelationId.Value.ToString()}'"); + builder.AppendLine($"'{CorrelationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanOverwrite), out propertyOverride); if (Optional.IsDefined(CanOverwrite) || hasPropertyOverride) { - builder.Append(" overwrite:"); + builder.Append(" overwrite: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CanOverwrite.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CloneCustomHostNames), out propertyOverride); if (Optional.IsDefined(CloneCustomHostNames) || hasPropertyOverride) { - builder.Append(" cloneCustomHostNames:"); + builder.Append(" cloneCustomHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CloneCustomHostNames.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CloneSourceControl), out propertyOverride); if (Optional.IsDefined(CloneSourceControl) || hasPropertyOverride) { - builder.Append(" cloneSourceControl:"); + builder.Append(" cloneSourceControl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CloneSourceControl.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceWebAppId), out propertyOverride); if (Optional.IsDefined(SourceWebAppId) || hasPropertyOverride) { - builder.Append(" sourceWebAppId:"); + builder.Append(" sourceWebAppId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceWebAppId.ToString()}'"); + builder.AppendLine($"'{SourceWebAppId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceWebAppLocation), out propertyOverride); if (Optional.IsDefined(SourceWebAppLocation) || hasPropertyOverride) { - builder.Append(" sourceWebAppLocation:"); + builder.Append(" sourceWebAppLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SourceWebAppLocation.Value.ToString()}'"); + builder.AppendLine($"'{SourceWebAppLocation.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironment), out propertyOverride); if (Optional.IsDefined(HostingEnvironment) || hasPropertyOverride) { - builder.Append(" hostingEnvironment:"); + builder.Append(" hostingEnvironment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HostingEnvironment.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HostingEnvironment}'''"); } else { - builder.AppendLine($" '{HostingEnvironment}'"); + builder.AppendLine($"'{HostingEnvironment}'"); } } } @@ -366,17 +366,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettingsOverrides.Any() || hasPropertyOverride) { - builder.Append(" appSettingsOverrides:"); + builder.Append(" appSettingsOverrides: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in AppSettingsOverrides) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -384,12 +384,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -400,50 +400,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConfigureLoadBalancing), out propertyOverride); if (Optional.IsDefined(ConfigureLoadBalancing) || hasPropertyOverride) { - builder.Append(" configureLoadBalancing:"); + builder.Append(" configureLoadBalancing: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ConfigureLoadBalancing.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TrafficManagerProfileId), out propertyOverride); if (Optional.IsDefined(TrafficManagerProfileId) || hasPropertyOverride) { - builder.Append(" trafficManagerProfileId:"); + builder.Append(" trafficManagerProfileId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TrafficManagerProfileId.ToString()}'"); + builder.AppendLine($"'{TrafficManagerProfileId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TrafficManagerProfileName), out propertyOverride); if (Optional.IsDefined(TrafficManagerProfileName) || hasPropertyOverride) { - builder.Append(" trafficManagerProfileName:"); + builder.Append(" trafficManagerProfileName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TrafficManagerProfileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TrafficManagerProfileName}'''"); } else { - builder.AppendLine($" '{TrafficManagerProfileName}'"); + builder.AppendLine($"'{TrafficManagerProfileName}'"); } } } @@ -452,12 +452,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -478,13 +481,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringInfo.Serialization.cs index 47b88b0c23900..351a9e94bee2f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringInfo.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionString), out propertyOverride); if (Optional.IsDefined(ConnectionString) || hasPropertyOverride) { - builder.Append(" connectionString:"); + builder.Append(" connectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionString}'''"); } else { - builder.AppendLine($" '{ConnectionString}'"); + builder.AppendLine($"'{ConnectionString}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringValueTypePair.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringValueTypePair.Serialization.cs index 5bc2c200cc59d..4c092a5c85117 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringValueTypePair.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnStringValueTypePair.Serialization.cs @@ -109,21 +109,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -132,12 +132,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -158,13 +161,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnectionStringDictionary.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnectionStringDictionary.Serialization.cs index 753819b654b68..81428510fdc83 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnectionStringDictionary.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ConnectionStringDictionary.Serialization.cs @@ -180,21 +180,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -204,18 +204,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Properties) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " properties: "); } builder.AppendLine(" }"); } @@ -225,21 +225,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -247,28 +247,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -276,12 +276,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -302,13 +305,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuStatistics.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuStatistics.Serialization.cs index 35ae6c5a960bc..7fc09f746d65a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuStatistics.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuStatistics.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CpuUsage), out propertyOverride); if (Optional.IsDefined(CpuUsage) || hasPropertyOverride) { - builder.Append(" cpuUsage:"); + builder.Append(" cpuUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CpuUsage, options, 2, false); + AppendChildObject(builder, CpuUsage, options, 2, false, " cpuUsage: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemCpuUsage), out propertyOverride); if (Optional.IsDefined(SystemCpuUsage) || hasPropertyOverride) { - builder.Append(" systemCpuUsage:"); + builder.Append(" systemCpuUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemCpuUsage.Value.ToString()}'"); + builder.AppendLine($"'{SystemCpuUsage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OnlineCpuCount), out propertyOverride); if (Optional.IsDefined(OnlineCpuCount) || hasPropertyOverride) { - builder.Append(" onlineCpuCount:"); + builder.Append(" onlineCpuCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {OnlineCpuCount.Value}"); + builder.AppendLine($"{OnlineCpuCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThrottlingData), out propertyOverride); if (Optional.IsDefined(ThrottlingData) || hasPropertyOverride) { - builder.Append(" throttlingData:"); + builder.Append(" throttlingData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ThrottlingData, options, 2, false); + AppendChildObject(builder, ThrottlingData, options, 2, false, " throttlingData: "); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuUsage.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuUsage.Serialization.cs index 63a9960ed7cc8..eadc0711f0f09 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuUsage.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerCpuUsage.Serialization.cs @@ -164,14 +164,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalUsage), out propertyOverride); if (Optional.IsDefined(TotalUsage) || hasPropertyOverride) { - builder.Append(" totalUsage:"); + builder.Append(" totalUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TotalUsage.Value.ToString()}'"); + builder.AppendLine($"'{TotalUsage.Value.ToString()}'"); } } @@ -180,14 +180,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PerCpuUsage.Any() || hasPropertyOverride) { - builder.Append(" perCpuUsage:"); + builder.Append(" perCpuUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PerCpuUsage) { builder.AppendLine($" '{item.ToString()}'"); @@ -200,28 +200,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KernelModeUsage), out propertyOverride); if (Optional.IsDefined(KernelModeUsage) || hasPropertyOverride) { - builder.Append(" kernelModeUsage:"); + builder.Append(" kernelModeUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{KernelModeUsage.Value.ToString()}'"); + builder.AppendLine($"'{KernelModeUsage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserModeUsage), out propertyOverride); if (Optional.IsDefined(UserModeUsage) || hasPropertyOverride) { - builder.Append(" userModeUsage:"); + builder.Append(" userModeUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UserModeUsage.Value.ToString()}'"); + builder.AppendLine($"'{UserModeUsage.Value.ToString()}'"); } } @@ -229,12 +229,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -255,13 +258,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerInfo.Serialization.cs index 8025de874425d..dbbd489abae70 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerInfo.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,93 +227,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentTimeStamp), out propertyOverride); if (Optional.IsDefined(CurrentTimeStamp) || hasPropertyOverride) { - builder.Append(" currentTimeStamp:"); + builder.Append(" currentTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CurrentTimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreviousTimeStamp), out propertyOverride); if (Optional.IsDefined(PreviousTimeStamp) || hasPropertyOverride) { - builder.Append(" previousTimeStamp:"); + builder.Append(" previousTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(PreviousTimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentCpuStats), out propertyOverride); if (Optional.IsDefined(CurrentCpuStats) || hasPropertyOverride) { - builder.Append(" currentCpuStats:"); + builder.Append(" currentCpuStats: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CurrentCpuStats, options, 2, false); + AppendChildObject(builder, CurrentCpuStats, options, 2, false, " currentCpuStats: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreviousCpuStats), out propertyOverride); if (Optional.IsDefined(PreviousCpuStats) || hasPropertyOverride) { - builder.Append(" previousCpuStats:"); + builder.Append(" previousCpuStats: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PreviousCpuStats, options, 2, false); + AppendChildObject(builder, PreviousCpuStats, options, 2, false, " previousCpuStats: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MemoryStats), out propertyOverride); if (Optional.IsDefined(MemoryStats) || hasPropertyOverride) { - builder.Append(" memoryStats:"); + builder.Append(" memoryStats: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MemoryStats, options, 2, false); + AppendChildObject(builder, MemoryStats, options, 2, false, " memoryStats: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -321,14 +321,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Eth0), out propertyOverride); if (Optional.IsDefined(Eth0) || hasPropertyOverride) { - builder.Append(" eth0:"); + builder.Append(" eth0: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Eth0, options, 2, false); + AppendChildObject(builder, Eth0, options, 2, false, " eth0: "); } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerMemoryStatistics.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerMemoryStatistics.Serialization.cs index 882cee963fe5a..fea9e8c863894 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerMemoryStatistics.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerMemoryStatistics.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Usage), out propertyOverride); if (Optional.IsDefined(Usage) || hasPropertyOverride) { - builder.Append(" usage:"); + builder.Append(" usage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Usage.Value.ToString()}'"); + builder.AppendLine($"'{Usage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxUsage), out propertyOverride); if (Optional.IsDefined(MaxUsage) || hasPropertyOverride) { - builder.Append(" maxUsage:"); + builder.Append(" maxUsage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxUsage.Value.ToString()}'"); + builder.AppendLine($"'{MaxUsage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerNetworkInterfaceStatistics.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerNetworkInterfaceStatistics.Serialization.cs index 2d0c5be5dbeb1..6b5503dc29a25 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerNetworkInterfaceStatistics.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerNetworkInterfaceStatistics.Serialization.cs @@ -213,112 +213,112 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RxBytes), out propertyOverride); if (Optional.IsDefined(RxBytes) || hasPropertyOverride) { - builder.Append(" rxBytes:"); + builder.Append(" rxBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RxBytes.Value.ToString()}'"); + builder.AppendLine($"'{RxBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RxPackets), out propertyOverride); if (Optional.IsDefined(RxPackets) || hasPropertyOverride) { - builder.Append(" rxPackets:"); + builder.Append(" rxPackets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RxPackets.Value.ToString()}'"); + builder.AppendLine($"'{RxPackets.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RxErrors), out propertyOverride); if (Optional.IsDefined(RxErrors) || hasPropertyOverride) { - builder.Append(" rxErrors:"); + builder.Append(" rxErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RxErrors.Value.ToString()}'"); + builder.AppendLine($"'{RxErrors.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RxDropped), out propertyOverride); if (Optional.IsDefined(RxDropped) || hasPropertyOverride) { - builder.Append(" rxDropped:"); + builder.Append(" rxDropped: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RxDropped.Value.ToString()}'"); + builder.AppendLine($"'{RxDropped.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TxBytes), out propertyOverride); if (Optional.IsDefined(TxBytes) || hasPropertyOverride) { - builder.Append(" txBytes:"); + builder.Append(" txBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TxBytes.Value.ToString()}'"); + builder.AppendLine($"'{TxBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TxPackets), out propertyOverride); if (Optional.IsDefined(TxPackets) || hasPropertyOverride) { - builder.Append(" txPackets:"); + builder.Append(" txPackets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TxPackets.Value.ToString()}'"); + builder.AppendLine($"'{TxPackets.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TxErrors), out propertyOverride); if (Optional.IsDefined(TxErrors) || hasPropertyOverride) { - builder.Append(" txErrors:"); + builder.Append(" txErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TxErrors.Value.ToString()}'"); + builder.AppendLine($"'{TxErrors.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TxDropped), out propertyOverride); if (Optional.IsDefined(TxDropped) || hasPropertyOverride) { - builder.Append(" txDropped:"); + builder.Append(" txDropped: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TxDropped.Value.ToString()}'"); + builder.AppendLine($"'{TxDropped.Value.ToString()}'"); } } @@ -326,12 +326,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -352,13 +355,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerThrottlingInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerThrottlingInfo.Serialization.cs index 7f2e4f3efb3d7..fb980f6d03c1c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerThrottlingInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContainerThrottlingInfo.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Periods), out propertyOverride); if (Optional.IsDefined(Periods) || hasPropertyOverride) { - builder.Append(" periods:"); + builder.Append(" periods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Periods.Value}"); + builder.AppendLine($"{Periods.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThrottledPeriods), out propertyOverride); if (Optional.IsDefined(ThrottledPeriods) || hasPropertyOverride) { - builder.Append(" throttledPeriods:"); + builder.Append(" throttledPeriods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ThrottledPeriods.Value}"); + builder.AppendLine($"{ThrottledPeriods.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThrottledTime), out propertyOverride); if (Optional.IsDefined(ThrottledTime) || hasPropertyOverride) { - builder.Append(" throttledTime:"); + builder.Append(" throttledTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ThrottledTime.Value}"); + builder.AppendLine($"{ThrottledTime.Value}"); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContinuousWebJobListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContinuousWebJobListResult.Serialization.cs index 64ac9536b263b..9db4c4148907f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContinuousWebJobListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ContinuousWebJobListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescription.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescription.Serialization.cs index 680c39433a4d8..75eb854928032 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescription.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescription.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -182,50 +182,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDataAction), out propertyOverride); if (Optional.IsDefined(IsDataAction) || hasPropertyOverride) { - builder.Append(" isDataAction:"); + builder.Append(" isDataAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDataAction.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Display), out propertyOverride); if (Optional.IsDefined(Display) || hasPropertyOverride) { - builder.Append(" display:"); + builder.Append(" display: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Display, options, 2, false); + AppendChildObject(builder, Display, options, 2, false, " display: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Origin), out propertyOverride); if (Optional.IsDefined(Origin) || hasPropertyOverride) { - builder.Append(" origin:"); + builder.Append(" origin: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Origin.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Origin}'''"); } else { - builder.AppendLine($" '{Origin}'"); + builder.AppendLine($"'{Origin}'"); } } } @@ -233,14 +233,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -248,12 +248,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -274,13 +277,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescriptionProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescriptionProperties.Serialization.cs index 2a39d621a0f41..354010e929ab6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescriptionProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDescriptionProperties.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceSpecification), out propertyOverride); if (Optional.IsDefined(ServiceSpecification) || hasPropertyOverride) { - builder.Append(" serviceSpecification:"); + builder.Append(" serviceSpecification: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ServiceSpecification, options, 2, false); + AppendChildObject(builder, ServiceSpecification, options, 2, false, " serviceSpecification: "); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDisplay.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDisplay.Serialization.cs index 3f33f734866ad..f3c36362ab4ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDisplay.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationDisplay.Serialization.cs @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -159,21 +159,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Resource), out propertyOverride); if (Optional.IsDefined(Resource) || hasPropertyOverride) { - builder.Append(" resource:"); + builder.Append(" resource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Resource.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Resource}'''"); } else { - builder.AppendLine($" '{Resource}'"); + builder.AppendLine($"'{Resource}'"); } } } @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operation), out propertyOverride); if (Optional.IsDefined(Operation) || hasPropertyOverride) { - builder.Append(" operation:"); + builder.Append(" operation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Operation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Operation}'''"); } else { - builder.AppendLine($" '{Operation}'"); + builder.AppendLine($"'{Operation}'"); } } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -226,12 +226,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -252,13 +255,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationListResult.Serialization.cs index 7848bb5cb6d19..48c089dda9533 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmOperationListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuota.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuota.Serialization.cs index 91106560a9112..853e8e64ca9e8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuota.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuota.Serialization.cs @@ -164,35 +164,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Name, options, 2, false); + AppendChildObject(builder, Name, options, 2, false, " name: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -200,43 +200,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextResetOn), out propertyOverride); if (Optional.IsDefined(NextResetOn) || hasPropertyOverride) { - builder.Append(" nextResetTime:"); + builder.Append(" nextResetTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(NextResetOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) { - builder.Append(" currentValue:"); + builder.Append(" currentValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CurrentValue.Value.ToString()}'"); + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); if (Optional.IsDefined(Limit) || hasPropertyOverride) { - builder.Append(" limit:"); + builder.Append(" limit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Limit.Value.ToString()}'"); + builder.AppendLine($"'{Limit.Value.ToString()}'"); } } @@ -244,12 +244,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -270,13 +273,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuotaListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuotaListResult.Serialization.cs index 89e4f38550f30..034a2db538a5c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuotaListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CsmUsageQuotaListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomHostnameAnalysisResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomHostnameAnalysisResult.Serialization.cs index f83e88092aa2c..8335599b9cb3f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomHostnameAnalysisResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomHostnameAnalysisResult.Serialization.cs @@ -381,21 +381,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -403,21 +403,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -425,28 +425,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -455,94 +455,94 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHostnameAlreadyVerified), out propertyOverride); if (Optional.IsDefined(IsHostnameAlreadyVerified) || hasPropertyOverride) { - builder.Append(" isHostnameAlreadyVerified:"); + builder.Append(" isHostnameAlreadyVerified: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHostnameAlreadyVerified.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationTest), out propertyOverride); if (Optional.IsDefined(CustomDomainVerificationTest) || hasPropertyOverride) { - builder.Append(" customDomainVerificationTest:"); + builder.Append(" customDomainVerificationTest: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CustomDomainVerificationTest.Value.ToSerialString()}'"); + builder.AppendLine($"'{CustomDomainVerificationTest.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationFailureInfo), out propertyOverride); if (Optional.IsDefined(CustomDomainVerificationFailureInfo) || hasPropertyOverride) { - builder.Append(" customDomainVerificationFailureInfo:"); + builder.Append(" customDomainVerificationFailureInfo: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CustomDomainVerificationFailureInfo, options, 4, false); + AppendChildObject(builder, CustomDomainVerificationFailureInfo, options, 4, false, " customDomainVerificationFailureInfo: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasConflictOnScaleUnit), out propertyOverride); if (Optional.IsDefined(HasConflictOnScaleUnit) || hasPropertyOverride) { - builder.Append(" hasConflictOnScaleUnit:"); + builder.Append(" hasConflictOnScaleUnit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasConflictOnScaleUnit.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasConflictAcrossSubscription), out propertyOverride); if (Optional.IsDefined(HasConflictAcrossSubscription) || hasPropertyOverride) { - builder.Append(" hasConflictAcrossSubscription:"); + builder.Append(" hasConflictAcrossSubscription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = HasConflictAcrossSubscription.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConflictingAppResourceId), out propertyOverride); if (Optional.IsDefined(ConflictingAppResourceId) || hasPropertyOverride) { - builder.Append(" conflictingAppResourceId:"); + builder.Append(" conflictingAppResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConflictingAppResourceId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConflictingAppResourceId}'''"); } else { - builder.AppendLine($" '{ConflictingAppResourceId}'"); + builder.AppendLine($"'{ConflictingAppResourceId}'"); } } } @@ -552,14 +552,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CNameRecords.Any() || hasPropertyOverride) { - builder.Append(" cNameRecords:"); + builder.Append(" cNameRecords: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CNameRecords) { if (item == null) @@ -587,14 +587,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TxtRecords.Any() || hasPropertyOverride) { - builder.Append(" txtRecords:"); + builder.Append(" txtRecords: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TxtRecords) { if (item == null) @@ -622,14 +622,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ARecords.Any() || hasPropertyOverride) { - builder.Append(" aRecords:"); + builder.Append(" aRecords: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ARecords) { if (item == null) @@ -657,14 +657,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AlternateCNameRecords.Any() || hasPropertyOverride) { - builder.Append(" alternateCNameRecords:"); + builder.Append(" alternateCNameRecords: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AlternateCNameRecords) { if (item == null) @@ -692,14 +692,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AlternateTxtRecords.Any() || hasPropertyOverride) { - builder.Append(" alternateTxtRecords:"); + builder.Append(" alternateTxtRecords: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AlternateTxtRecords) { if (item == null) @@ -727,12 +727,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -753,13 +756,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomOpenIdConnectProvider.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomOpenIdConnectProvider.Serialization.cs index 8ebfdc70ba062..5d069b011e99e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomOpenIdConnectProvider.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/CustomOpenIdConnectProvider.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderKeyValuePair.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderKeyValuePair.Serialization.cs index 6ca31789de5e1..2bbdddc0ca89e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderKeyValuePair.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderKeyValuePair.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Key.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Key}'''"); } else { - builder.AppendLine($" '{Key}'"); + builder.AppendLine($"'{Key}'"); } } } @@ -148,14 +148,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.ToString()}'"); + builder.AppendLine($"'{Value.ToString()}'"); } } @@ -163,12 +163,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -189,13 +192,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderMetadata.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderMetadata.Serialization.cs index 4f965833137dd..a83ca71b8b085 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderMetadata.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataProviderMetadata.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderName), out propertyOverride); if (Optional.IsDefined(ProviderName) || hasPropertyOverride) { - builder.Append(" providerName:"); + builder.Append(" providerName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProviderName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProviderName}'''"); } else { - builder.AppendLine($" '{ProviderName}'"); + builder.AppendLine($"'{ProviderName}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PropertyBag.Any() || hasPropertyOverride) { - builder.Append(" propertyBag:"); + builder.Append(" propertyBag: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PropertyBag) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " propertyBag: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseColumn.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseColumn.Serialization.cs index 7218a9b26dddf..5c2716545b338 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseColumn.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseColumn.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnName), out propertyOverride); if (Optional.IsDefined(ColumnName) || hasPropertyOverride) { - builder.Append(" columnName:"); + builder.Append(" columnName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ColumnName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ColumnName}'''"); } else { - builder.AppendLine($" '{ColumnName}'"); + builder.AppendLine($"'{ColumnName}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); if (Optional.IsDefined(DataType) || hasPropertyOverride) { - builder.Append(" dataType:"); + builder.Append(" dataType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DataType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DataType}'''"); } else { - builder.AppendLine($" '{DataType}'"); + builder.AppendLine($"'{DataType}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnType), out propertyOverride); if (Optional.IsDefined(ColumnType) || hasPropertyOverride) { - builder.Append(" columnType:"); + builder.Append(" columnType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ColumnType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ColumnType}'''"); } else { - builder.AppendLine($" '{ColumnType}'"); + builder.AppendLine($"'{ColumnType}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseObject.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseObject.Serialization.cs index 3a982725accd3..3d4ea029b6cda 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseObject.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DataTableResponseObject.Serialization.cs @@ -177,21 +177,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); if (Optional.IsDefined(TableName) || hasPropertyOverride) { - builder.Append(" tableName:"); + builder.Append(" tableName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TableName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TableName}'''"); } else { - builder.AppendLine($" '{TableName}'"); + builder.AppendLine($"'{TableName}'"); } } } @@ -201,17 +201,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Columns.Any() || hasPropertyOverride) { - builder.Append(" columns:"); + builder.Append(" columns: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Columns) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " columns: "); } builder.AppendLine(" ]"); } @@ -223,14 +223,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Rows.Any() || hasPropertyOverride) { - builder.Append(" rows:"); + builder.Append(" rows: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Rows) { if (item == null) @@ -238,7 +238,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { if (item0 == null) @@ -267,12 +267,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -293,13 +296,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DefaultAuthorizationPolicy.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DefaultAuthorizationPolicy.Serialization.cs index 6ca5c627edbd4..6f4a183aaa007 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DefaultAuthorizationPolicy.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DefaultAuthorizationPolicy.Serialization.cs @@ -134,14 +134,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedPrincipals), out propertyOverride); if (Optional.IsDefined(AllowedPrincipals) || hasPropertyOverride) { - builder.Append(" allowedPrincipals:"); + builder.Append(" allowedPrincipals: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AllowedPrincipals, options, 2, false); + AppendChildObject(builder, AllowedPrincipals, options, 2, false, " allowedPrincipals: "); } } @@ -150,14 +150,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedApplications.Any() || hasPropertyOverride) { - builder.Append(" allowedApplications:"); + builder.Append(" allowedApplications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedApplications) { if (item == null) @@ -184,12 +184,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -210,13 +213,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedAppRestoreContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedAppRestoreContent.Serialization.cs index 8678b83ddd536..5c4b6c72398f5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedAppRestoreContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedAppRestoreContent.Serialization.cs @@ -224,21 +224,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -268,28 +268,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -298,50 +298,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeletedSiteId), out propertyOverride); if (Optional.IsDefined(DeletedSiteId) || hasPropertyOverride) { - builder.Append(" deletedSiteId:"); + builder.Append(" deletedSiteId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DeletedSiteId.ToString()}'"); + builder.AppendLine($"'{DeletedSiteId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoverConfiguration), out propertyOverride); if (Optional.IsDefined(RecoverConfiguration) || hasPropertyOverride) { - builder.Append(" recoverConfiguration:"); + builder.Append(" recoverConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = RecoverConfiguration.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnapshotTime), out propertyOverride); if (Optional.IsDefined(SnapshotTime) || hasPropertyOverride) { - builder.Append(" snapshotTime:"); + builder.Append(" snapshotTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SnapshotTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SnapshotTime}'''"); } else { - builder.AppendLine($" '{SnapshotTime}'"); + builder.AppendLine($"'{SnapshotTime}'"); } } } @@ -349,15 +349,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UseDRSecondary), out propertyOverride); if (Optional.IsDefined(UseDRSecondary) || hasPropertyOverride) { - builder.Append(" useDRSecondary:"); + builder.Append(" useDRSecondary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UseDRSecondary.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -366,12 +366,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -392,13 +395,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedWebAppListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedWebAppListResult.Serialization.cs index 4bcda49988ec0..ad0ecdd5f081c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedWebAppListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DeletedWebAppListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorAbnormalTimePeriod.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorAbnormalTimePeriod.Serialization.cs index 4f6900adf1bb8..c698f0ca532ad 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorAbnormalTimePeriod.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorAbnormalTimePeriod.Serialization.cs @@ -248,51 +248,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -300,21 +300,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); if (Optional.IsDefined(Source) || hasPropertyOverride) { - builder.Append(" source:"); + builder.Append(" source: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Source.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Source}'''"); } else { - builder.AppendLine($" '{Source}'"); + builder.AppendLine($"'{Source}'"); } } } @@ -322,14 +322,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Priority), out propertyOverride); if (Optional.IsDefined(Priority) || hasPropertyOverride) { - builder.Append(" priority:"); + builder.Append(" priority: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Priority.Value.ToString()}'"); + builder.AppendLine($"'{Priority.Value.ToString()}'"); } } @@ -338,14 +338,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MetaData.Any() || hasPropertyOverride) { - builder.Append(" metaData:"); + builder.Append(" metaData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MetaData) { if (item == null) @@ -353,10 +353,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { - AppendChildObject(builder, item0, options, 4, true); + AppendChildObject(builder, item0, options, 4, true, " metaData: "); } builder.AppendLine(" ]"); } @@ -370,17 +370,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Solutions.Any() || hasPropertyOverride) { - builder.Append(" solutions:"); + builder.Append(" solutions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Solutions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " solutions: "); } builder.AppendLine(" ]"); } @@ -391,12 +391,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -417,13 +420,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDataSource.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDataSource.Serialization.cs index e1a9349d008bd..cab6a0cca91ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDataSource.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDataSource.Serialization.cs @@ -146,14 +146,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Instructions.Any() || hasPropertyOverride) { - builder.Append(" instructions:"); + builder.Append(" instructions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Instructions) { if (item == null) @@ -181,17 +181,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DataSourceUri.Any() || hasPropertyOverride) { - builder.Append(" dataSourceUri:"); + builder.Append(" dataSourceUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DataSourceUri) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " dataSourceUri: "); } builder.AppendLine(" ]"); } @@ -202,12 +202,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -228,13 +231,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDefinition.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDefinition.Serialization.cs index dd1d8bc903213..3b255b2150e6e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDefinition.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorDefinition.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -189,29 +189,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rank), out propertyOverride); if (Optional.IsDefined(Rank) || hasPropertyOverride) { - builder.Append(" rank:"); + builder.Append(" rank: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Rank.Value.ToString()}'"); + builder.AppendLine($"'{Rank.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" isEnabled:"); + builder.Append(" isEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -219,12 +219,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -245,13 +248,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorInfo.Serialization.cs index 6508236ad694a..dfc745328b879 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorInfo.Serialization.cs @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -273,21 +273,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -295,21 +295,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Author), out propertyOverride); if (Optional.IsDefined(Author) || hasPropertyOverride) { - builder.Append(" author:"); + builder.Append(" author: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Author.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Author}'''"); } else { - builder.AppendLine($" '{Author}'"); + builder.AppendLine($"'{Author}'"); } } } @@ -317,21 +317,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -341,17 +341,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportTopicList.Any() || hasPropertyOverride) { - builder.Append(" supportTopicList:"); + builder.Append(" supportTopicList: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportTopicList) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " supportTopicList: "); } builder.AppendLine(" ]"); } @@ -363,14 +363,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AnalysisType.Any() || hasPropertyOverride) { - builder.Append(" analysisType:"); + builder.Append(" analysisType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AnalysisType) { if (item == null) @@ -396,14 +396,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Score), out propertyOverride); if (Optional.IsDefined(Score) || hasPropertyOverride) { - builder.Append(" score:"); + builder.Append(" score: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Score.Value.ToString()}'"); + builder.AppendLine($"'{Score.Value.ToString()}'"); } } @@ -411,12 +411,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -437,13 +440,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorMetadata.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorMetadata.Serialization.cs index dc3f9ab302b02..0a519d222ddbd 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorMetadata.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorMetadata.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataSource), out propertyOverride); if (Optional.IsDefined(DataSource) || hasPropertyOverride) { - builder.Append(" dataSource:"); + builder.Append(" dataSource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DataSource, options, 2, false); + AppendChildObject(builder, DataSource, options, 2, false, " dataSource: "); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorSupportTopic.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorSupportTopic.Serialization.cs index 04827b4332158..717e424147b84 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorSupportTopic.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DetectorSupportTopic.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Id.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($" '{Id}'"); + builder.AppendLine($"'{Id}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PesId), out propertyOverride); if (Optional.IsDefined(PesId) || hasPropertyOverride) { - builder.Append(" pesId:"); + builder.Append(" pesId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PesId.ToString()}'"); + builder.AppendLine($"'{PesId.ToString()}'"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticAnalysis.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticAnalysis.Serialization.cs index 41d5acc4b5ea9..8ba99fa012e25 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticAnalysis.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticAnalysis.Serialization.cs @@ -274,21 +274,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -296,21 +296,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -318,28 +318,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -348,30 +348,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -380,17 +380,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AbnormalTimePeriods.Any() || hasPropertyOverride) { - builder.Append(" abnormalTimePeriods:"); + builder.Append(" abnormalTimePeriods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AbnormalTimePeriods) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " abnormalTimePeriods: "); } builder.AppendLine(" ]"); } @@ -402,17 +402,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Payload.Any() || hasPropertyOverride) { - builder.Append(" payload:"); + builder.Append(" payload: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Payload) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " payload: "); } builder.AppendLine(" ]"); } @@ -424,17 +424,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (NonCorrelatedDetectors.Any() || hasPropertyOverride) { - builder.Append(" nonCorrelatedDetectors:"); + builder.Append(" nonCorrelatedDetectors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in NonCorrelatedDetectors) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " nonCorrelatedDetectors: "); } builder.AppendLine(" ]"); } @@ -446,12 +446,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -472,13 +475,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticCategoryListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticCategoryListResult.Serialization.cs index 1ae27936fe219..88844b9de8452 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticCategoryListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticCategoryListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataRendering.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataRendering.Serialization.cs index 0a24ed72e3833..d4a9d9c9bff76 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataRendering.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataRendering.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); if (Optional.IsDefined(Title) || hasPropertyOverride) { - builder.Append(" title:"); + builder.Append(" title: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Title.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Title}'''"); } else { - builder.AppendLine($" '{Title}'"); + builder.AppendLine($"'{Title}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataset.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataset.Serialization.cs index fc613cc55870d..96cb7f35e19da 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataset.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDataset.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Table), out propertyOverride); if (Optional.IsDefined(Table) || hasPropertyOverride) { - builder.Append(" table:"); + builder.Append(" table: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Table, options, 2, false); + AppendChildObject(builder, Table, options, 2, false, " table: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RenderingProperties), out propertyOverride); if (Optional.IsDefined(RenderingProperties) || hasPropertyOverride) { - builder.Append(" renderingProperties:"); + builder.Append(" renderingProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RenderingProperties, options, 2, false); + AppendChildObject(builder, RenderingProperties, options, 2, false, " renderingProperties: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorListResult.Serialization.cs index e07e58c7c2a00..cf0684aa21f37 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorResponse.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorResponse.Serialization.cs index 1d32f626f527e..8aaf4d16766c5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorResponse.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticDetectorResponse.Serialization.cs @@ -341,21 +341,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -385,28 +385,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -415,59 +415,59 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IssueDetected), out propertyOverride); if (Optional.IsDefined(IssueDetected) || hasPropertyOverride) { - builder.Append(" issueDetected:"); + builder.Append(" issueDetected: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IssueDetected.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetectorDefinition), out propertyOverride); if (Optional.IsDefined(DetectorDefinition) || hasPropertyOverride) { - builder.Append(" detectorDefinition:"); + builder.Append(" detectorDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, DetectorDefinition, options, 4, false); + AppendChildObject(builder, DetectorDefinition, options, 4, false, " detectorDefinition: "); } } @@ -476,17 +476,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metrics.Any() || hasPropertyOverride) { - builder.Append(" metrics:"); + builder.Append(" metrics: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Metrics) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " metrics: "); } builder.AppendLine(" ]"); } @@ -498,17 +498,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AbnormalTimePeriods.Any() || hasPropertyOverride) { - builder.Append(" abnormalTimePeriods:"); + builder.Append(" abnormalTimePeriods: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AbnormalTimePeriods) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " abnormalTimePeriods: "); } builder.AppendLine(" ]"); } @@ -520,14 +520,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Data.Any() || hasPropertyOverride) { - builder.Append(" data:"); + builder.Append(" data: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Data) { if (item == null) @@ -535,10 +535,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { - AppendChildObject(builder, item0, options, 6, true); + AppendChildObject(builder, item0, options, 6, true, " data: "); } builder.AppendLine(" ]"); } @@ -550,14 +550,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResponseMetaData), out propertyOverride); if (Optional.IsDefined(ResponseMetaData) || hasPropertyOverride) { - builder.Append(" responseMetaData:"); + builder.Append(" responseMetaData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ResponseMetaData, options, 4, false); + AppendChildObject(builder, ResponseMetaData, options, 4, false, " responseMetaData: "); } } @@ -566,12 +566,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -592,13 +595,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSample.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSample.Serialization.cs index a055d56808b19..ea195e501b625 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSample.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSample.Serialization.cs @@ -179,36 +179,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); if (Optional.IsDefined(Timestamp) || hasPropertyOverride) { - builder.Append(" timestamp:"); + builder.Append(" timestamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RoleInstance), out propertyOverride); if (Optional.IsDefined(RoleInstance) || hasPropertyOverride) { - builder.Append(" roleInstance:"); + builder.Append(" roleInstance: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RoleInstance.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RoleInstance}'''"); } else { - builder.AppendLine($" '{RoleInstance}'"); + builder.AppendLine($"'{RoleInstance}'"); } } } @@ -216,57 +216,57 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Total), out propertyOverride); if (Optional.IsDefined(Total) || hasPropertyOverride) { - builder.Append(" total:"); + builder.Append(" total: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Total.Value.ToString()}'"); + builder.AppendLine($"'{Total.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Maximum), out propertyOverride); if (Optional.IsDefined(Maximum) || hasPropertyOverride) { - builder.Append(" maximum:"); + builder.Append(" maximum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Maximum.Value.ToString()}'"); + builder.AppendLine($"'{Maximum.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Minimum), out propertyOverride); if (Optional.IsDefined(Minimum) || hasPropertyOverride) { - builder.Append(" minimum:"); + builder.Append(" minimum: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Minimum.Value.ToString()}'"); + builder.AppendLine($"'{Minimum.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAggregated), out propertyOverride); if (Optional.IsDefined(IsAggregated) || hasPropertyOverride) { - builder.Append(" isAggregated:"); + builder.Append(" isAggregated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAggregated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSet.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSet.Serialization.cs index 9e04fa4e94cad..aef5c06ab5945 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSet.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticMetricSet.Serialization.cs @@ -182,21 +182,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -204,21 +204,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -226,51 +226,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -280,17 +280,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Values.Any() || hasPropertyOverride) { - builder.Append(" values:"); + builder.Append(" values: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Values) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " values: "); } builder.AppendLine(" ]"); } @@ -301,12 +301,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -327,13 +330,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticSolution.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticSolution.Serialization.cs index f75fd497e2460..532f81bd7a1e9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticSolution.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DiagnosticSolution.Serialization.cs @@ -255,35 +255,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.Value.ToString()}'"); + builder.AppendLine($"'{Id.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -291,35 +291,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Order), out propertyOverride); if (Optional.IsDefined(Order) || hasPropertyOverride) { - builder.Append(" order:"); + builder.Append(" order: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Order.Value.ToString()}'"); + builder.AppendLine($"'{Order.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -329,14 +329,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Data.Any() || hasPropertyOverride) { - builder.Append(" data:"); + builder.Append(" data: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Data) { if (item == null) @@ -344,10 +344,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { - AppendChildObject(builder, item0, options, 4, true); + AppendChildObject(builder, item0, options, 4, true, " data: "); } builder.AppendLine(" ]"); } @@ -361,14 +361,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Metadata.Any() || hasPropertyOverride) { - builder.Append(" metadata:"); + builder.Append(" metadata: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Metadata) { if (item == null) @@ -376,10 +376,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.Append("null"); continue; } - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item0 in item) { - AppendChildObject(builder, item0, options, 4, true); + AppendChildObject(builder, item0, options, 4, true, " metadata: "); } builder.AppendLine(" ]"); } @@ -392,12 +392,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -418,13 +421,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainAvailabilityCheckResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainAvailabilityCheckResult.Serialization.cs index e5c70f25e3a6f..23ca188620bdc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainAvailabilityCheckResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainAvailabilityCheckResult.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,29 +156,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAvailable), out propertyOverride); if (Optional.IsDefined(IsAvailable) || hasPropertyOverride) { - builder.Append(" available:"); + builder.Append(" available: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainType), out propertyOverride); if (Optional.IsDefined(DomainType) || hasPropertyOverride) { - builder.Append(" domainType:"); + builder.Append(" domainType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DomainType.Value.ToSerialString()}'"); + builder.AppendLine($"'{DomainType.Value.ToSerialString()}'"); } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainControlCenterSsoRequestInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainControlCenterSsoRequestInfo.Serialization.cs index e89331d306800..6cb8952313eab 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainControlCenterSsoRequestInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainControlCenterSsoRequestInfo.Serialization.cs @@ -130,35 +130,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PostParameterKey), out propertyOverride); if (Optional.IsDefined(PostParameterKey) || hasPropertyOverride) { - builder.Append(" postParameterKey:"); + builder.Append(" postParameterKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PostParameterKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PostParameterKey}'''"); } else { - builder.AppendLine($" '{PostParameterKey}'"); + builder.AppendLine($"'{PostParameterKey}'"); } } } @@ -166,21 +166,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PostParameterValue), out propertyOverride); if (Optional.IsDefined(PostParameterValue) || hasPropertyOverride) { - builder.Append(" postParameterValue:"); + builder.Append(" postParameterValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PostParameterValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PostParameterValue}'''"); } else { - builder.AppendLine($" '{PostParameterValue}'"); + builder.AppendLine($"'{PostParameterValue}'"); } } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainOwnershipIdentifierListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainOwnershipIdentifierListResult.Serialization.cs index 296147b2d8791..329ae29b0aa0a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainOwnershipIdentifierListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainOwnershipIdentifierListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainPurchaseConsent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainPurchaseConsent.Serialization.cs index 1a23bdbf23969..ec00b29d014f3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainPurchaseConsent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/DomainPurchaseConsent.Serialization.cs @@ -147,14 +147,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AgreementKeys.Any() || hasPropertyOverride) { - builder.Append(" agreementKeys:"); + builder.Append(" agreementKeys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AgreementKeys) { if (item == null) @@ -180,21 +180,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgreedBy), out propertyOverride); if (Optional.IsDefined(AgreedBy) || hasPropertyOverride) { - builder.Append(" agreedBy:"); + builder.Append(" agreedBy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AgreedBy.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AgreedBy}'''"); } else { - builder.AppendLine($" '{AgreedBy}'"); + builder.AppendLine($"'{AgreedBy}'"); } } } @@ -202,15 +202,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgreedOn), out propertyOverride); if (Optional.IsDefined(AgreedOn) || hasPropertyOverride) { - builder.Append(" agreedAt:"); + builder.Append(" agreedAt: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(AgreedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -218,12 +218,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -244,13 +247,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemApplicationLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemApplicationLogsConfig.Serialization.cs index d1923fd389cf6..62a6d13e2372c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemApplicationLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemApplicationLogsConfig.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.Value.ToSerialString()}'"); + builder.AppendLine($"'{Level.Value.ToSerialString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemHttpLogsConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemHttpLogsConfig.Serialization.cs index 9cb3b2ac81717..6182c5f16c7eb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemHttpLogsConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemHttpLogsConfig.Serialization.cs @@ -138,43 +138,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInMb), out propertyOverride); if (Optional.IsDefined(RetentionInMb) || hasPropertyOverride) { - builder.Append(" retentionInMb:"); + builder.Append(" retentionInMb: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionInMb.Value}"); + builder.AppendLine($"{RetentionInMb.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) { - builder.Append(" retentionInDays:"); + builder.Append(" retentionInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionInDays.Value}"); + builder.AppendLine($"{RetentionInDays.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -182,12 +182,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -208,13 +211,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemTokenStore.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemTokenStore.Serialization.cs index 13f9220ee8111..14537720213e7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemTokenStore.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FileSystemTokenStore.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Directory), out propertyOverride); if (Optional.IsDefined(Directory) || hasPropertyOverride) { - builder.Append(" directory:"); + builder.Append(" directory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Directory.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Directory}'''"); } else { - builder.AppendLine($" '{Directory}'"); + builder.AppendLine($"'{Directory}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FrontEndConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FrontEndConfiguration.Serialization.cs index e2a8f09c2cf6d..413d144c5c09c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FrontEndConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FrontEndConfiguration.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Kind.Value.ToSerialString()}'"); + builder.AppendLine($"'{Kind.Value.ToSerialString()}'"); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppHostKeys.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppHostKeys.Serialization.cs index 887ed45f24460..c532a6350581e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppHostKeys.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppHostKeys.Serialization.cs @@ -157,21 +157,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MasterKey), out propertyOverride); if (Optional.IsDefined(MasterKey) || hasPropertyOverride) { - builder.Append(" masterKey:"); + builder.Append(" masterKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MasterKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MasterKey}'''"); } else { - builder.AppendLine($" '{MasterKey}'"); + builder.AppendLine($"'{MasterKey}'"); } } } @@ -181,17 +181,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FunctionKeys.Any() || hasPropertyOverride) { - builder.Append(" functionKeys:"); + builder.Append(" functionKeys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in FunctionKeys) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -199,12 +199,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -217,17 +217,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SystemKeys.Any() || hasPropertyOverride) { - builder.Append(" systemKeys:"); + builder.Append(" systemKeys: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in SystemKeys) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -235,12 +235,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -252,12 +252,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -278,13 +281,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMajorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMajorVersion.Serialization.cs index 5f2b9a2685e1c..32c80430bb184 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMajorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMajorVersion.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -187,17 +187,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MinorVersions.Any() || hasPropertyOverride) { - builder.Append(" minorVersions:"); + builder.Append(" minorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MinorVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " minorVersions: "); } builder.AppendLine(" ]"); } @@ -208,12 +208,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -234,13 +237,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMinorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMinorVersion.Serialization.cs index e471bb697047c..79dac6626f157 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMinorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppMinorVersion.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StackSettings), out propertyOverride); if (Optional.IsDefined(StackSettings) || hasPropertyOverride) { - builder.Append(" stackSettings:"); + builder.Append(" stackSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StackSettings, options, 2, false); + AppendChildObject(builder, StackSettings, options, 2, false, " stackSettings: "); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimeSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimeSettings.Serialization.cs index 06dd867121878..fd3594552ca1f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimeSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimeSettings.Serialization.cs @@ -321,21 +321,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -343,43 +343,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRemoteDebuggingSupported), out propertyOverride); if (Optional.IsDefined(IsRemoteDebuggingSupported) || hasPropertyOverride) { - builder.Append(" remoteDebuggingSupported:"); + builder.Append(" remoteDebuggingSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRemoteDebuggingSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppInsightsSettings), out propertyOverride); if (Optional.IsDefined(AppInsightsSettings) || hasPropertyOverride) { - builder.Append(" appInsightsSettings:"); + builder.Append(" appInsightsSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AppInsightsSettings, options, 2, false); + AppendChildObject(builder, AppInsightsSettings, options, 2, false, " appInsightsSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubActionSettings), out propertyOverride); if (Optional.IsDefined(GitHubActionSettings) || hasPropertyOverride) { - builder.Append(" gitHubActionSettings:"); + builder.Append(" gitHubActionSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GitHubActionSettings, options, 2, false); + AppendChildObject(builder, GitHubActionSettings, options, 2, false, " gitHubActionSettings: "); } } @@ -388,17 +388,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettingsDictionary.Any() || hasPropertyOverride) { - builder.Append(" appSettingsDictionary:"); + builder.Append(" appSettingsDictionary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in AppSettingsDictionary) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -406,12 +406,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -422,14 +422,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteConfigPropertiesDictionary), out propertyOverride); if (Optional.IsDefined(SiteConfigPropertiesDictionary) || hasPropertyOverride) { - builder.Append(" siteConfigPropertiesDictionary:"); + builder.Append(" siteConfigPropertiesDictionary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SiteConfigPropertiesDictionary, options, 2, false); + AppendChildObject(builder, SiteConfigPropertiesDictionary, options, 2, false, " siteConfigPropertiesDictionary: "); } } @@ -438,14 +438,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedFunctionsExtensionVersions.Any() || hasPropertyOverride) { - builder.Append(" supportedFunctionsExtensionVersions:"); + builder.Append(" supportedFunctionsExtensionVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedFunctionsExtensionVersions) { if (item == null) @@ -471,105 +471,105 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreview), out propertyOverride); if (Optional.IsDefined(IsPreview) || hasPropertyOverride) { - builder.Append(" isPreview:"); + builder.Append(" isPreview: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreview.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeprecated), out propertyOverride); if (Optional.IsDefined(IsDeprecated) || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeprecated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); if (Optional.IsDefined(IsHidden) || hasPropertyOverride) { - builder.Append(" isHidden:"); + builder.Append(" isHidden: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHidden.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOfLifeOn), out propertyOverride); if (Optional.IsDefined(EndOfLifeOn) || hasPropertyOverride) { - builder.Append(" endOfLifeDate:"); + builder.Append(" endOfLifeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOfLifeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoUpdate), out propertyOverride); if (Optional.IsDefined(IsAutoUpdate) || hasPropertyOverride) { - builder.Append(" isAutoUpdate:"); + builder.Append(" isAutoUpdate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoUpdate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEarlyAccess), out propertyOverride); if (Optional.IsDefined(IsEarlyAccess) || hasPropertyOverride) { - builder.Append(" isEarlyAccess:"); + builder.Append(" isEarlyAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEarlyAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefault), out propertyOverride); if (Optional.IsDefined(IsDefault) || hasPropertyOverride) { - builder.Append(" isDefault:"); + builder.Append(" isDefault: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefault.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -577,12 +577,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -603,13 +606,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimes.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimes.Serialization.cs index 2d31875247cb6..cf21c9872d093 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimes.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppRuntimes.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxRuntimeSettings), out propertyOverride); if (Optional.IsDefined(LinuxRuntimeSettings) || hasPropertyOverride) { - builder.Append(" linuxRuntimeSettings:"); + builder.Append(" linuxRuntimeSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LinuxRuntimeSettings, options, 2, false); + AppendChildObject(builder, LinuxRuntimeSettings, options, 2, false, " linuxRuntimeSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WindowsRuntimeSettings), out propertyOverride); if (Optional.IsDefined(WindowsRuntimeSettings) || hasPropertyOverride) { - builder.Append(" windowsRuntimeSettings:"); + builder.Append(" windowsRuntimeSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, WindowsRuntimeSettings, options, 2, false); + AppendChildObject(builder, WindowsRuntimeSettings, options, 2, false, " windowsRuntimeSettings: "); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStack.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStack.Serialization.cs index 0017a7266df94..96cc51f69454d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStack.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStack.Serialization.cs @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -268,35 +268,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -304,28 +304,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -334,21 +334,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -356,21 +356,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -380,17 +380,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MajorVersions.Any() || hasPropertyOverride) { - builder.Append(" majorVersions:"); + builder.Append(" majorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MajorVersions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " majorVersions: "); } builder.AppendLine(" ]"); } @@ -400,14 +400,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreferredOS), out propertyOverride); if (Optional.IsDefined(PreferredOS) || hasPropertyOverride) { - builder.Append(" preferredOs:"); + builder.Append(" preferredOs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PreferredOS.Value.ToSerialString()}'"); + builder.AppendLine($"'{PreferredOS.Value.ToSerialString()}'"); } } @@ -416,12 +416,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -442,13 +445,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStackListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStackListResult.Serialization.cs index a2671cba40420..5037baa1e87c4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStackListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionAppStackListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionEnvelopeListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionEnvelopeListResult.Serialization.cs index 15ab2dba65f6d..5b29c89529b8e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionEnvelopeListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionEnvelopeListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionSecrets.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionSecrets.Serialization.cs index bf9436af8dcbd..ac497744886cc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionSecrets.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/FunctionSecrets.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Key.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Key}'''"); } else { - builder.AppendLine($" '{Key}'"); + builder.AppendLine($"'{Key}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerUri), out propertyOverride); if (Optional.IsDefined(TriggerUri) || hasPropertyOverride) { - builder.Append(" trigger_url:"); + builder.Append(" trigger_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TriggerUri.AbsoluteUri}'"); + builder.AppendLine($"'{TriggerUri.AbsoluteUri}'"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionCodeConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionCodeConfiguration.Serialization.cs index 688bb824bd227..0079b5b337d34 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionCodeConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionCodeConfiguration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeStack), out propertyOverride); if (Optional.IsDefined(RuntimeStack) || hasPropertyOverride) { - builder.Append(" runtimeStack:"); + builder.Append(" runtimeStack: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeStack.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeStack}'''"); } else { - builder.AppendLine($" '{RuntimeStack}'"); + builder.AppendLine($"'{RuntimeStack}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionConfiguration.Serialization.cs index d5228067d4750..488b7d1a78648 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionConfiguration.Serialization.cs @@ -153,58 +153,58 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CodeConfiguration), out propertyOverride); if (Optional.IsDefined(CodeConfiguration) || hasPropertyOverride) { - builder.Append(" codeConfiguration:"); + builder.Append(" codeConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CodeConfiguration, options, 2, false); + AppendChildObject(builder, CodeConfiguration, options, 2, false, " codeConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerConfiguration), out propertyOverride); if (Optional.IsDefined(ContainerConfiguration) || hasPropertyOverride) { - builder.Append(" containerConfiguration:"); + builder.Append(" containerConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ContainerConfiguration, options, 2, false); + AppendChildObject(builder, ContainerConfiguration, options, 2, false, " containerConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLinux), out propertyOverride); if (Optional.IsDefined(IsLinux) || hasPropertyOverride) { - builder.Append(" isLinux:"); + builder.Append(" isLinux: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLinux.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GenerateWorkflowFile), out propertyOverride); if (Optional.IsDefined(GenerateWorkflowFile) || hasPropertyOverride) { - builder.Append(" generateWorkflowFile:"); + builder.Append(" generateWorkflowFile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = GenerateWorkflowFile.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -212,12 +212,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -238,13 +241,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionContainerConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionContainerConfiguration.Serialization.cs index b06e1d6302ee4..79b282b4b9c24 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionContainerConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionContainerConfiguration.Serialization.cs @@ -141,35 +141,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerUri), out propertyOverride); if (Optional.IsDefined(ServerUri) || hasPropertyOverride) { - builder.Append(" serverUrl:"); + builder.Append(" serverUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerUri.AbsoluteUri}'"); + builder.AppendLine($"'{ServerUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImageName), out propertyOverride); if (Optional.IsDefined(ImageName) || hasPropertyOverride) { - builder.Append(" imageName:"); + builder.Append(" imageName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ImageName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ImageName}'''"); } else { - builder.AppendLine($" '{ImageName}'"); + builder.AppendLine($"'{ImageName}'"); } } } @@ -177,21 +177,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Username), out propertyOverride); if (Optional.IsDefined(Username) || hasPropertyOverride) { - builder.Append(" username:"); + builder.Append(" username: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Username.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Username}'''"); } else { - builder.AppendLine($" '{Username}'"); + builder.AppendLine($"'{Username}'"); } } } @@ -199,21 +199,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); if (Optional.IsDefined(Password) || hasPropertyOverride) { - builder.Append(" password:"); + builder.Append(" password: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Password.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Password}'''"); } else { - builder.AppendLine($" '{Password}'"); + builder.AppendLine($"'{Password}'"); } } } @@ -222,12 +222,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -248,13 +251,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionWebAppStackSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionWebAppStackSettings.Serialization.cs index c35e44700c35f..b3f46a020ca68 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionWebAppStackSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GitHubActionWebAppStackSettings.Serialization.cs @@ -119,36 +119,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSupported), out propertyOverride); if (Optional.IsDefined(IsSupported) || hasPropertyOverride) { - builder.Append(" isSupported:"); + builder.Append(" isSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedVersion), out propertyOverride); if (Optional.IsDefined(SupportedVersion) || hasPropertyOverride) { - builder.Append(" supportedVersion:"); + builder.Append(" supportedVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SupportedVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SupportedVersion}'''"); } else { - builder.AppendLine($" '{SupportedVersion}'"); + builder.AppendLine($"'{SupportedVersion}'"); } } } @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalCsmSkuDescription.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalCsmSkuDescription.Serialization.cs index e0fa2cc84c3f3..3faa848b25e46 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalCsmSkuDescription.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalCsmSkuDescription.Serialization.cs @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -225,21 +225,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); if (Optional.IsDefined(Tier) || hasPropertyOverride) { - builder.Append(" tier:"); + builder.Append(" tier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Tier.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Tier}'''"); } else { - builder.AppendLine($" '{Tier}'"); + builder.AppendLine($"'{Tier}'"); } } } @@ -247,21 +247,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); if (Optional.IsDefined(Size) || hasPropertyOverride) { - builder.Append(" size:"); + builder.Append(" size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Size.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Size}'''"); } else { - builder.AppendLine($" '{Size}'"); + builder.AppendLine($"'{Size}'"); } } } @@ -269,21 +269,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); if (Optional.IsDefined(Family) || hasPropertyOverride) { - builder.Append(" family:"); + builder.Append(" family: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Family.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Family}'''"); } else { - builder.AppendLine($" '{Family}'"); + builder.AppendLine($"'{Family}'"); } } } @@ -291,14 +291,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); if (Optional.IsDefined(Capacity) || hasPropertyOverride) { - builder.Append(" capacity:"); + builder.Append(" capacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Capacity, options, 2, false); + AppendChildObject(builder, Capacity, options, 2, false, " capacity: "); } } @@ -307,14 +307,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Locations.Any() || hasPropertyOverride) { - builder.Append(" locations:"); + builder.Append(" locations: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Locations) { builder.AppendLine($" '{item.ToString()}'"); @@ -329,17 +329,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Capabilities.Any() || hasPropertyOverride) { - builder.Append(" capabilities:"); + builder.Append(" capabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Capabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " capabilities: "); } builder.AppendLine(" ]"); } @@ -350,12 +350,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -376,13 +379,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalValidation.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalValidation.Serialization.cs index 814bddefea131..9f2c233a585be 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalValidation.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/GlobalValidation.Serialization.cs @@ -160,50 +160,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAuthenticationRequired), out propertyOverride); if (Optional.IsDefined(IsAuthenticationRequired) || hasPropertyOverride) { - builder.Append(" requireAuthentication:"); + builder.Append(" requireAuthentication: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAuthenticationRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UnauthenticatedClientAction), out propertyOverride); if (Optional.IsDefined(UnauthenticatedClientAction) || hasPropertyOverride) { - builder.Append(" unauthenticatedClientAction:"); + builder.Append(" unauthenticatedClientAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UnauthenticatedClientAction.Value.ToSerialString()}'"); + builder.AppendLine($"'{UnauthenticatedClientAction.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RedirectToProvider), out propertyOverride); if (Optional.IsDefined(RedirectToProvider) || hasPropertyOverride) { - builder.Append(" redirectToProvider:"); + builder.Append(" redirectToProvider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RedirectToProvider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RedirectToProvider}'''"); } else { - builder.AppendLine($" '{RedirectToProvider}'"); + builder.AppendLine($"'{RedirectToProvider}'"); } } } @@ -213,14 +213,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ExcludedPaths.Any() || hasPropertyOverride) { - builder.Append(" excludedPaths:"); + builder.Append(" excludedPaths: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ExcludedPaths) { if (item == null) @@ -247,12 +247,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -273,13 +276,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameBindingListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameBindingListResult.Serialization.cs index 02b64a9d58645..0523ebca4b9fe 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameBindingListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameBindingListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameSslState.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameSslState.Serialization.cs index e3e325077a97c..8d6be8a85bebc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameSslState.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostNameSslState.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,35 +201,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SslState), out propertyOverride); if (Optional.IsDefined(SslState) || hasPropertyOverride) { - builder.Append(" sslState:"); + builder.Append(" sslState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SslState.Value.ToSerialString()}'"); + builder.AppendLine($"'{SslState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualIP), out propertyOverride); if (Optional.IsDefined(VirtualIP) || hasPropertyOverride) { - builder.Append(" virtualIP:"); + builder.Append(" virtualIP: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualIP.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualIP}'''"); } else { - builder.AppendLine($" '{VirtualIP}'"); + builder.AppendLine($"'{VirtualIP}'"); } } } @@ -237,21 +237,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -259,29 +259,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ToUpdate), out propertyOverride); if (Optional.IsDefined(ToUpdate) || hasPropertyOverride) { - builder.Append(" toUpdate:"); + builder.Append(" toUpdate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ToUpdate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostType), out propertyOverride); if (Optional.IsDefined(HostType) || hasPropertyOverride) { - builder.Append(" hostType:"); + builder.Append(" hostType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{HostType.Value.ToSerialString()}'"); + builder.AppendLine($"'{HostType.Value.ToSerialString()}'"); } } @@ -289,12 +289,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -315,13 +318,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDeploymentInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDeploymentInfo.Serialization.cs index f200800420a67..900ecf93dd94d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDeploymentInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDeploymentInfo.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDiagnostics.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDiagnostics.Serialization.cs index bb7b16bc49386..b7b4716eddcf3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDiagnostics.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentDiagnostics.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DiagnosticsOutput), out propertyOverride); if (Optional.IsDefined(DiagnosticsOutput) || hasPropertyOverride) { - builder.Append(" diagnosticsOutput:"); + builder.Append(" diagnosticsOutput: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DiagnosticsOutput.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DiagnosticsOutput}'''"); } else { - builder.AppendLine($" '{DiagnosticsOutput}'"); + builder.AppendLine($"'{DiagnosticsOutput}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentProfile.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentProfile.Serialization.cs index f44c7d79e392c..31ab4693322a4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentProfile.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HostingEnvironmentProfile.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,14 +156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HttpRequestHandlerMapping.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HttpRequestHandlerMapping.Serialization.cs index e308cfa0e51ac..4ceb5a5246b9c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HttpRequestHandlerMapping.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HttpRequestHandlerMapping.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Extension), out propertyOverride); if (Optional.IsDefined(Extension) || hasPropertyOverride) { - builder.Append(" extension:"); + builder.Append(" extension: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Extension.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Extension}'''"); } else { - builder.AppendLine($" '{Extension}'"); + builder.AppendLine($"'{Extension}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScriptProcessor), out propertyOverride); if (Optional.IsDefined(ScriptProcessor) || hasPropertyOverride) { - builder.Append(" scriptProcessor:"); + builder.Append(" scriptProcessor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ScriptProcessor.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ScriptProcessor}'''"); } else { - builder.AppendLine($" '{ScriptProcessor}'"); + builder.AppendLine($"'{ScriptProcessor}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); if (Optional.IsDefined(Arguments) || hasPropertyOverride) { - builder.Append(" arguments:"); + builder.Append(" arguments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Arguments.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Arguments}'''"); } else { - builder.AppendLine($" '{Arguments}'"); + builder.AppendLine($"'{Arguments}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionKey.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionKey.Serialization.cs index 07d79ffa73566..8a4c4f1c0e2e0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionKey.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionKey.Serialization.cs @@ -190,21 +190,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -212,21 +212,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -234,28 +234,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendKeyName), out propertyOverride); if (Optional.IsDefined(SendKeyName) || hasPropertyOverride) { - builder.Append(" sendKeyName:"); + builder.Append(" sendKeyName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SendKeyName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SendKeyName}'''"); } else { - builder.AppendLine($" '{SendKeyName}'"); + builder.AppendLine($"'{SendKeyName}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendKeyValue), out propertyOverride); if (Optional.IsDefined(SendKeyValue) || hasPropertyOverride) { - builder.Append(" sendKeyValue:"); + builder.Append(" sendKeyValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SendKeyValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SendKeyValue}'''"); } else { - builder.AppendLine($" '{SendKeyValue}'"); + builder.AppendLine($"'{SendKeyValue}'"); } } } @@ -310,12 +310,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -336,13 +339,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionListResult.Serialization.cs index ef8d3d065a87c..0cbda791491a0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/HybridConnectionListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpoint.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpoint.Serialization.cs index ca7dd3a17f6f0..48696a915778c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpoint.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpoint.Serialization.cs @@ -155,21 +155,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -179,14 +179,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Endpoints.Any() || hasPropertyOverride) { - builder.Append(" endpoints:"); + builder.Append(" endpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Endpoints) { if (item == null) @@ -214,14 +214,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Ports.Any() || hasPropertyOverride) { - builder.Append(" ports:"); + builder.Append(" ports: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Ports) { if (item == null) @@ -248,12 +248,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -274,13 +277,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpointListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpointListResult.Serialization.cs index 91fc8dc8642a8..60a816d56bb83 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpointListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/InboundEnvironmentEndpointListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/JwtClaimChecks.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/JwtClaimChecks.Serialization.cs index fdbd6807816b6..0563d8430f846 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/JwtClaimChecks.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/JwtClaimChecks.Serialization.cs @@ -146,14 +146,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedGroups.Any() || hasPropertyOverride) { - builder.Append(" allowedGroups:"); + builder.Append(" allowedGroups: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedGroups) { if (item == null) @@ -181,14 +181,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedClientApplications.Any() || hasPropertyOverride) { - builder.Append(" allowedClientApplications:"); + builder.Append(" allowedClientApplications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedClientApplications) { if (item == null) @@ -215,12 +215,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -241,13 +244,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentListResult.Serialization.cs index 63168dd9e086d..198523fc09613 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentPatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentPatch.Serialization.cs index d748651664f49..fbf702b39c25b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentPatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentPatch.Serialization.cs @@ -276,21 +276,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -298,21 +298,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -320,28 +320,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -350,35 +350,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProvisioningState.Value.ToSerialString()}'"); + builder.AppendLine($"'{ProvisioningState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentErrors), out propertyOverride); if (Optional.IsDefined(DeploymentErrors) || hasPropertyOverride) { - builder.Append(" deploymentErrors:"); + builder.Append(" deploymentErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeploymentErrors.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeploymentErrors}'''"); } else { - builder.AppendLine($" '{DeploymentErrors}'"); + builder.AppendLine($"'{DeploymentErrors}'"); } } } @@ -386,36 +386,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInternalLoadBalancerEnabled), out propertyOverride); if (Optional.IsDefined(IsInternalLoadBalancerEnabled) || hasPropertyOverride) { - builder.Append(" internalLoadBalancerEnabled:"); + builder.Append(" internalLoadBalancerEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInternalLoadBalancerEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDomain), out propertyOverride); if (Optional.IsDefined(DefaultDomain) || hasPropertyOverride) { - builder.Append(" defaultDomain:"); + builder.Append(" defaultDomain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultDomain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultDomain}'''"); } else { - builder.AppendLine($" '{DefaultDomain}'"); + builder.AppendLine($"'{DefaultDomain}'"); } } } @@ -423,21 +423,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StaticIP), out propertyOverride); if (Optional.IsDefined(StaticIP) || hasPropertyOverride) { - builder.Append(" staticIp:"); + builder.Append(" staticIp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StaticIP.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StaticIP}'''"); } else { - builder.AppendLine($" '{StaticIP}'"); + builder.AppendLine($"'{StaticIP}'"); } } } @@ -445,42 +445,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArcConfiguration), out propertyOverride); if (Optional.IsDefined(ArcConfiguration) || hasPropertyOverride) { - builder.Append(" arcConfiguration:"); + builder.Append(" arcConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ArcConfiguration, options, 4, false); + AppendChildObject(builder, ArcConfiguration, options, 4, false, " arcConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppLogsConfiguration), out propertyOverride); if (Optional.IsDefined(AppLogsConfiguration) || hasPropertyOverride) { - builder.Append(" appLogsConfiguration:"); + builder.Append(" appLogsConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AppLogsConfiguration, options, 4, false); + AppendChildObject(builder, AppLogsConfiguration, options, 4, false, " appLogsConfiguration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AksResourceId), out propertyOverride); if (Optional.IsDefined(AksResourceId) || hasPropertyOverride) { - builder.Append(" aksResourceID:"); + builder.Append(" aksResourceID: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AksResourceId.ToString()}'"); + builder.AppendLine($"'{AksResourceId.ToString()}'"); } } @@ -489,12 +489,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -515,13 +518,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentProfile.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentProfile.Serialization.cs index 9e5260931a6b9..3f9e75d042cca 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentProfile.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/KubeEnvironmentProfile.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -156,14 +156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -171,12 +171,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -197,13 +200,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LegacyMicrosoftAccount.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LegacyMicrosoftAccount.Serialization.cs index 175fafcc5bc52..e9f703cd914d4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LegacyMicrosoftAccount.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LegacyMicrosoftAccount.Serialization.cs @@ -153,57 +153,57 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); if (Optional.IsDefined(Registration) || hasPropertyOverride) { - builder.Append(" registration:"); + builder.Append(" registration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Registration, options, 2, false); + AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 2, false); + AppendChildObject(builder, Login, options, 2, false, " login: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); if (Optional.IsDefined(Validation) || hasPropertyOverride) { - builder.Append(" validation:"); + builder.Append(" validation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Validation, options, 2, false); + AppendChildObject(builder, Validation, options, 2, false, " validation: "); } } @@ -211,12 +211,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -237,13 +240,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LinuxJavaContainerSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LinuxJavaContainerSettings.Serialization.cs index c91c3c1467cef..f331a3570428b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LinuxJavaContainerSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LinuxJavaContainerSettings.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Java11Runtime), out propertyOverride); if (Optional.IsDefined(Java11Runtime) || hasPropertyOverride) { - builder.Append(" java11Runtime:"); + builder.Append(" java11Runtime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Java11Runtime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Java11Runtime}'''"); } else { - builder.AppendLine($" '{Java11Runtime}'"); + builder.AppendLine($"'{Java11Runtime}'"); } } } @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Java8Runtime), out propertyOverride); if (Optional.IsDefined(Java8Runtime) || hasPropertyOverride) { - builder.Append(" java8Runtime:"); + builder.Append(" java8Runtime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Java8Runtime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Java8Runtime}'''"); } else { - builder.AppendLine($" '{Java8Runtime}'"); + builder.AppendLine($"'{Java8Runtime}'"); } } } @@ -249,90 +249,90 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreview), out propertyOverride); if (Optional.IsDefined(IsPreview) || hasPropertyOverride) { - builder.Append(" isPreview:"); + builder.Append(" isPreview: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreview.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeprecated), out propertyOverride); if (Optional.IsDefined(IsDeprecated) || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeprecated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); if (Optional.IsDefined(IsHidden) || hasPropertyOverride) { - builder.Append(" isHidden:"); + builder.Append(" isHidden: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHidden.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOfLifeOn), out propertyOverride); if (Optional.IsDefined(EndOfLifeOn) || hasPropertyOverride) { - builder.Append(" endOfLifeDate:"); + builder.Append(" endOfLifeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOfLifeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoUpdate), out propertyOverride); if (Optional.IsDefined(IsAutoUpdate) || hasPropertyOverride) { - builder.Append(" isAutoUpdate:"); + builder.Append(" isAutoUpdate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoUpdate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEarlyAccess), out propertyOverride); if (Optional.IsDefined(IsEarlyAccess) || hasPropertyOverride) { - builder.Append(" isEarlyAccess:"); + builder.Append(" isEarlyAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEarlyAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LocalizableString.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LocalizableString.Serialization.cs index 05becad239b4b..f68a0a1db0fc3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LocalizableString.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LocalizableString.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalizedValue), out propertyOverride); if (Optional.IsDefined(LocalizedValue) || hasPropertyOverride) { - builder.Append(" localizedValue:"); + builder.Append(" localizedValue: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalizedValue.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalizedValue}'''"); } else { - builder.AppendLine($" '{LocalizedValue}'"); + builder.AppendLine($"'{LocalizedValue}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogAnalyticsConfiguration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogAnalyticsConfiguration.Serialization.cs index 69e33598ca44d..50560a44018f2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogAnalyticsConfiguration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogAnalyticsConfiguration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerId), out propertyOverride); if (Optional.IsDefined(CustomerId) || hasPropertyOverride) { - builder.Append(" customerId:"); + builder.Append(" customerId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CustomerId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CustomerId}'''"); } else { - builder.AppendLine($" '{CustomerId}'"); + builder.AppendLine($"'{CustomerId}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SharedKey), out propertyOverride); if (Optional.IsDefined(SharedKey) || hasPropertyOverride) { - builder.Append(" sharedKey:"); + builder.Append(" sharedKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SharedKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SharedKey}'''"); } else { - builder.AppendLine($" '{SharedKey}'"); + builder.AppendLine($"'{SharedKey}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogSpecification.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogSpecification.Serialization.cs index ee9dfd7bf9239..464272bcb2059 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogSpecification.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LogSpecification.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -185,36 +185,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobDuration), out propertyOverride); if (Optional.IsDefined(BlobDuration) || hasPropertyOverride) { - builder.Append(" blobDuration:"); + builder.Append(" blobDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(BlobDuration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogFilterPattern), out propertyOverride); if (Optional.IsDefined(LogFilterPattern) || hasPropertyOverride) { - builder.Append(" logFilterPattern:"); + builder.Append(" logFilterPattern: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LogFilterPattern.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LogFilterPattern}'''"); } else { - builder.AppendLine($" '{LogFilterPattern}'"); + builder.AppendLine($"'{LogFilterPattern}'"); } } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginFlowNonceSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginFlowNonceSettings.Serialization.cs index 41a5e6b4fd6f8..c1ff569f5f412 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginFlowNonceSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginFlowNonceSettings.Serialization.cs @@ -119,36 +119,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidateNonce), out propertyOverride); if (Optional.IsDefined(ValidateNonce) || hasPropertyOverride) { - builder.Append(" validateNonce:"); + builder.Append(" validateNonce: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ValidateNonce.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NonceExpirationInterval), out propertyOverride); if (Optional.IsDefined(NonceExpirationInterval) || hasPropertyOverride) { - builder.Append(" nonceExpirationInterval:"); + builder.Append(" nonceExpirationInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NonceExpirationInterval.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NonceExpirationInterval}'''"); } else { - builder.AppendLine($" '{NonceExpirationInterval}'"); + builder.AppendLine($"'{NonceExpirationInterval}'"); } } } @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginRoutes.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginRoutes.Serialization.cs index e7143a0c8c966..9555067411eaa 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginRoutes.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginRoutes.Serialization.cs @@ -104,21 +104,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogoutEndpoint), out propertyOverride); if (Optional.IsDefined(LogoutEndpoint) || hasPropertyOverride) { - builder.Append(" logoutEndpoint:"); + builder.Append(" logoutEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LogoutEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LogoutEndpoint}'''"); } else { - builder.AppendLine($" '{LogoutEndpoint}'"); + builder.AppendLine($"'{LogoutEndpoint}'"); } } } @@ -127,12 +127,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -153,13 +156,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginScopes.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginScopes.Serialization.cs index d1fb1bc6bc275..3f79e7c26f2bb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginScopes.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/LoginScopes.Serialization.cs @@ -121,14 +121,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Scopes.Any() || hasPropertyOverride) { - builder.Append(" scopes:"); + builder.Append(" scopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Scopes) { if (item == null) @@ -155,12 +155,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -181,13 +184,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricAvailability.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricAvailability.Serialization.cs index cfbf173cb108d..8ad14f9a8de51 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricAvailability.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricAvailability.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -141,15 +141,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobDuration), out propertyOverride); if (Optional.IsDefined(BlobDuration) || hasPropertyOverride) { - builder.Append(" blobDuration:"); + builder.Append(" blobDuration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(BlobDuration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } @@ -157,12 +157,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -183,13 +186,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricDimension.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricDimension.Serialization.cs index d5eb910949393..61ded3a17ce54 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricDimension.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricDimension.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -185,21 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalName), out propertyOverride); if (Optional.IsDefined(InternalName) || hasPropertyOverride) { - builder.Append(" internalName:"); + builder.Append(" internalName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InternalName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InternalName}'''"); } else { - builder.AppendLine($" '{InternalName}'"); + builder.AppendLine($"'{InternalName}'"); } } } @@ -207,15 +207,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsToBeExportedForShoebox), out propertyOverride); if (Optional.IsDefined(IsToBeExportedForShoebox) || hasPropertyOverride) { - builder.Append(" toBeExportedForShoebox:"); + builder.Append(" toBeExportedForShoebox: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsToBeExportedForShoebox.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricSpecification.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricSpecification.Serialization.cs index cabe9955aab5e..21c4d83889d45 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricSpecification.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MetricSpecification.Serialization.cs @@ -353,21 +353,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -375,21 +375,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -397,21 +397,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayDescription), out propertyOverride); if (Optional.IsDefined(DisplayDescription) || hasPropertyOverride) { - builder.Append(" displayDescription:"); + builder.Append(" displayDescription: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayDescription}'''"); } else { - builder.AppendLine($" '{DisplayDescription}'"); + builder.AppendLine($"'{DisplayDescription}'"); } } } @@ -419,21 +419,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -441,21 +441,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AggregationType), out propertyOverride); if (Optional.IsDefined(AggregationType) || hasPropertyOverride) { - builder.Append(" aggregationType:"); + builder.Append(" aggregationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AggregationType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AggregationType}'''"); } else { - builder.AppendLine($" '{AggregationType}'"); + builder.AppendLine($"'{AggregationType}'"); } } } @@ -463,51 +463,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInstanceLevelAggregationSupported), out propertyOverride); if (Optional.IsDefined(IsInstanceLevelAggregationSupported) || hasPropertyOverride) { - builder.Append(" supportsInstanceLevelAggregation:"); + builder.Append(" supportsInstanceLevelAggregation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInstanceLevelAggregationSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRegionalMdmAccountEnabled), out propertyOverride); if (Optional.IsDefined(IsRegionalMdmAccountEnabled) || hasPropertyOverride) { - builder.Append(" enableRegionalMdmAccount:"); + builder.Append(" enableRegionalMdmAccount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRegionalMdmAccountEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceMdmAccount), out propertyOverride); if (Optional.IsDefined(SourceMdmAccount) || hasPropertyOverride) { - builder.Append(" sourceMdmAccount:"); + builder.Append(" sourceMdmAccount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceMdmAccount.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceMdmAccount}'''"); } else { - builder.AppendLine($" '{SourceMdmAccount}'"); + builder.AppendLine($"'{SourceMdmAccount}'"); } } } @@ -515,21 +515,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceMdmNamespace), out propertyOverride); if (Optional.IsDefined(SourceMdmNamespace) || hasPropertyOverride) { - builder.Append(" sourceMdmNamespace:"); + builder.Append(" sourceMdmNamespace: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceMdmNamespace.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceMdmNamespace}'''"); } else { - builder.AppendLine($" '{SourceMdmNamespace}'"); + builder.AppendLine($"'{SourceMdmNamespace}'"); } } } @@ -537,21 +537,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricFilterPattern), out propertyOverride); if (Optional.IsDefined(MetricFilterPattern) || hasPropertyOverride) { - builder.Append(" metricFilterPattern:"); + builder.Append(" metricFilterPattern: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MetricFilterPattern.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MetricFilterPattern}'''"); } else { - builder.AppendLine($" '{MetricFilterPattern}'"); + builder.AppendLine($"'{MetricFilterPattern}'"); } } } @@ -559,30 +559,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FillGapWithZero), out propertyOverride); if (Optional.IsDefined(FillGapWithZero) || hasPropertyOverride) { - builder.Append(" fillGapWithZero:"); + builder.Append(" fillGapWithZero: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = FillGapWithZero.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInternal), out propertyOverride); if (Optional.IsDefined(IsInternal) || hasPropertyOverride) { - builder.Append(" isInternal:"); + builder.Append(" isInternal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInternal.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -591,17 +591,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Dimensions.Any() || hasPropertyOverride) { - builder.Append(" dimensions:"); + builder.Append(" dimensions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Dimensions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " dimensions: "); } builder.AppendLine(" ]"); } @@ -611,21 +611,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -635,17 +635,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Availabilities.Any() || hasPropertyOverride) { - builder.Append(" availabilities:"); + builder.Append(" availabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Availabilities) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " availabilities: "); } builder.AppendLine(" ]"); } @@ -657,14 +657,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedTimeGrainTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedTimeGrainTypes:"); + builder.Append(" supportedTimeGrainTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedTimeGrainTypes) { if (item == null) @@ -692,14 +692,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SupportedAggregationTypes.Any() || hasPropertyOverride) { - builder.Append(" supportedAggregationTypes:"); + builder.Append(" supportedAggregationTypes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in SupportedAggregationTypes) { if (item == null) @@ -726,12 +726,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -752,13 +755,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MigrateMySqlContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MigrateMySqlContent.Serialization.cs index fb65b7bf105c2..42286f0cbb9c8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MigrateMySqlContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/MigrateMySqlContent.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionString), out propertyOverride); if (Optional.IsDefined(ConnectionString) || hasPropertyOverride) { - builder.Append(" connectionString:"); + builder.Append(" connectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionString}'''"); } else { - builder.AppendLine($" '{ConnectionString}'"); + builder.AppendLine($"'{ConnectionString}'"); } } } @@ -290,14 +290,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MigrationType), out propertyOverride); if (Optional.IsDefined(MigrationType) || hasPropertyOverride) { - builder.Append(" migrationType:"); + builder.Append(" migrationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MigrationType.Value.ToSerialString()}'"); + builder.AppendLine($"'{MigrationType.Value.ToSerialString()}'"); } } @@ -306,12 +306,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -332,13 +335,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectClientCredential.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectClientCredential.Serialization.cs index dd86afbaa79a2..874aa72708dc7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectClientCredential.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectClientCredential.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Method), out propertyOverride); if (Optional.IsDefined(Method) || hasPropertyOverride) { - builder.Append(" method:"); + builder.Append(" method: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Method.Value.ToString()}'"); + builder.AppendLine($"'{Method.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" clientSecretSettingName:"); + builder.Append(" clientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{ClientSecretSettingName}'"); + builder.AppendLine($"'{ClientSecretSettingName}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectConfig.Serialization.cs index 8451306218068..ca2055d80e3da 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectConfig.Serialization.cs @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthorizationEndpoint), out propertyOverride); if (Optional.IsDefined(AuthorizationEndpoint) || hasPropertyOverride) { - builder.Append(" authorizationEndpoint:"); + builder.Append(" authorizationEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthorizationEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthorizationEndpoint}'''"); } else { - builder.AppendLine($" '{AuthorizationEndpoint}'"); + builder.AppendLine($"'{AuthorizationEndpoint}'"); } } } @@ -174,21 +174,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenEndpoint), out propertyOverride); if (Optional.IsDefined(TokenEndpoint) || hasPropertyOverride) { - builder.Append(" tokenEndpoint:"); + builder.Append(" tokenEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TokenEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TokenEndpoint}'''"); } else { - builder.AppendLine($" '{TokenEndpoint}'"); + builder.AppendLine($"'{TokenEndpoint}'"); } } } @@ -196,21 +196,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); if (Optional.IsDefined(Issuer) || hasPropertyOverride) { - builder.Append(" issuer:"); + builder.Append(" issuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Issuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Issuer}'''"); } else { - builder.AppendLine($" '{Issuer}'"); + builder.AppendLine($"'{Issuer}'"); } } } @@ -218,35 +218,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificationUri), out propertyOverride); if (Optional.IsDefined(CertificationUri) || hasPropertyOverride) { - builder.Append(" certificationUri:"); + builder.Append(" certificationUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{CertificationUri.AbsoluteUri}'"); + builder.AppendLine($"'{CertificationUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WellKnownOpenIdConfiguration), out propertyOverride); if (Optional.IsDefined(WellKnownOpenIdConfiguration) || hasPropertyOverride) { - builder.Append(" wellKnownOpenIdConfiguration:"); + builder.Append(" wellKnownOpenIdConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WellKnownOpenIdConfiguration.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WellKnownOpenIdConfiguration}'''"); } else { - builder.AppendLine($" '{WellKnownOpenIdConfiguration}'"); + builder.AppendLine($"'{WellKnownOpenIdConfiguration}'"); } } } @@ -255,12 +255,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -281,13 +284,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectLogin.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectLogin.Serialization.cs index 3c29b384930d0..9763c5be0c74e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectLogin.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectLogin.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameClaimType), out propertyOverride); if (Optional.IsDefined(NameClaimType) || hasPropertyOverride) { - builder.Append(" nameClaimType:"); + builder.Append(" nameClaimType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameClaimType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameClaimType}'''"); } else { - builder.AppendLine($" '{NameClaimType}'"); + builder.AppendLine($"'{NameClaimType}'"); } } } @@ -154,14 +154,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Scopes.Any() || hasPropertyOverride) { - builder.Append(" scopes:"); + builder.Append(" scopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Scopes) { if (item == null) @@ -188,12 +188,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -214,13 +217,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectRegistration.Serialization.cs index e55a42373c8eb..13f9cad5b69c6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OpenIdConnectRegistration.Serialization.cs @@ -134,21 +134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -156,28 +156,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCredential), out propertyOverride); if (Optional.IsDefined(ClientCredential) || hasPropertyOverride) { - builder.Append(" clientCredential:"); + builder.Append(" clientCredential: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ClientCredential, options, 2, false); + AppendChildObject(builder, ClientCredential, options, 2, false, " clientCredential: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OpenIdConnectConfiguration), out propertyOverride); if (Optional.IsDefined(OpenIdConnectConfiguration) || hasPropertyOverride) { - builder.Append(" openIdConnectConfiguration:"); + builder.Append(" openIdConnectConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, OpenIdConnectConfiguration, options, 2, false); + AppendChildObject(builder, OpenIdConnectConfiguration, options, 2, false, " openIdConnectConfiguration: "); } } @@ -185,12 +185,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -211,13 +214,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs index 40b3240e23906..4f5c5181e85a1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Endpoints.Any() || hasPropertyOverride) { - builder.Append(" endpoints:"); + builder.Append(" endpoints: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Endpoints) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " endpoints: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpointListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpointListResult.Serialization.cs index 708a7c23eb9af..386b105e23c79 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpointListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/OutboundEnvironmentEndpointListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonCounterListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonCounterListResult.Serialization.cs index ec3212d0f411d..d0c746b62cea3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonCounterListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonCounterListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonResponseInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonResponseInfo.Serialization.cs index 267cf461135a5..a1e9062038837 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonResponseInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonResponseInfo.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); if (Optional.IsDefined(Code) || hasPropertyOverride) { - builder.Append(" code:"); + builder.Append(" code: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Code.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Code}'''"); } else { - builder.AppendLine($" '{Code}'"); + builder.AppendLine($"'{Code}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Data), out propertyOverride); if (Optional.IsDefined(Data) || hasPropertyOverride) { - builder.Append(" data:"); + builder.Append(" data: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Data, options, 2, false); + AppendChildObject(builder, Data, options, 2, false, " data: "); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSample.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSample.Serialization.cs index 422cdb6fda716..4995b20422fe7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSample.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSample.Serialization.cs @@ -134,36 +134,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Time), out propertyOverride); if (Optional.IsDefined(Time) || hasPropertyOverride) { - builder.Append(" time:"); + builder.Append(" time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Time.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InstanceName), out propertyOverride); if (Optional.IsDefined(InstanceName) || hasPropertyOverride) { - builder.Append(" instanceName:"); + builder.Append(" instanceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InstanceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InstanceName}'''"); } else { - builder.AppendLine($" '{InstanceName}'"); + builder.AppendLine($"'{InstanceName}'"); } } } @@ -171,14 +171,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Value.Value.ToString()}'"); + builder.AppendLine($"'{Value.Value.ToString()}'"); } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSet.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSet.Serialization.cs index 1916cd72a217f..b2a0a8bf393fb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSet.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PerfMonSet.Serialization.cs @@ -171,21 +171,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,51 +193,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" endTime:"); + builder.Append(" endTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -247,17 +247,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Values.Any() || hasPropertyOverride) { - builder.Append(" values:"); + builder.Append(" values: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Values) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " values: "); } builder.AppendLine(" ]"); } @@ -268,12 +268,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -294,13 +297,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOffer.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOffer.Serialization.cs index f7db4443177fb..d5e99f1c02090 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOffer.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOffer.Serialization.cs @@ -298,21 +298,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -320,21 +320,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -342,28 +342,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -372,21 +372,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Sku.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Sku}'''"); } else { - builder.AppendLine($" '{Sku}'"); + builder.AppendLine($"'{Sku}'"); } } } @@ -394,21 +394,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -416,21 +416,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Vendor), out propertyOverride); if (Optional.IsDefined(Vendor) || hasPropertyOverride) { - builder.Append(" vendor:"); + builder.Append(" vendor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Vendor.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Vendor}'''"); } else { - builder.AppendLine($" '{Vendor}'"); + builder.AppendLine($"'{Vendor}'"); } } } @@ -438,92 +438,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPromoCodeRequired), out propertyOverride); if (Optional.IsDefined(IsPromoCodeRequired) || hasPropertyOverride) { - builder.Append(" promoCodeRequired:"); + builder.Append(" promoCodeRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPromoCodeRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Quota), out propertyOverride); if (Optional.IsDefined(Quota) || hasPropertyOverride) { - builder.Append(" quota:"); + builder.Append(" quota: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Quota.Value}"); + builder.AppendLine($"{Quota.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebHostingPlanRestrictions), out propertyOverride); if (Optional.IsDefined(WebHostingPlanRestrictions) || hasPropertyOverride) { - builder.Append(" webHostingPlanRestrictions:"); + builder.Append(" webHostingPlanRestrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebHostingPlanRestrictions.Value.ToSerialString()}'"); + builder.AppendLine($"'{WebHostingPlanRestrictions.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivacyPolicyUri), out propertyOverride); if (Optional.IsDefined(PrivacyPolicyUri) || hasPropertyOverride) { - builder.Append(" privacyPolicyUrl:"); + builder.Append(" privacyPolicyUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrivacyPolicyUri.AbsoluteUri}'"); + builder.AppendLine($"'{PrivacyPolicyUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LegalTermsUri), out propertyOverride); if (Optional.IsDefined(LegalTermsUri) || hasPropertyOverride) { - builder.Append(" legalTermsUrl:"); + builder.Append(" legalTermsUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LegalTermsUri.AbsoluteUri}'"); + builder.AppendLine($"'{LegalTermsUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplacePublisher), out propertyOverride); if (Optional.IsDefined(MarketplacePublisher) || hasPropertyOverride) { - builder.Append(" marketplacePublisher:"); + builder.Append(" marketplacePublisher: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplacePublisher.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplacePublisher}'''"); } else { - builder.AppendLine($" '{MarketplacePublisher}'"); + builder.AppendLine($"'{MarketplacePublisher}'"); } } } @@ -531,21 +531,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplaceOffer), out propertyOverride); if (Optional.IsDefined(MarketplaceOffer) || hasPropertyOverride) { - builder.Append(" marketplaceOffer:"); + builder.Append(" marketplaceOffer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplaceOffer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplaceOffer}'''"); } else { - builder.AppendLine($" '{MarketplaceOffer}'"); + builder.AppendLine($"'{MarketplaceOffer}'"); } } } @@ -555,12 +555,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -581,13 +584,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOfferListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOfferListResult.Serialization.cs index fa4d16195d22b..ecc4749eb0dbb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOfferListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnOfferListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnPatchResource.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnPatchResource.Serialization.cs index fe229271fdc4d..dc2a0f9e6354d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnPatchResource.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PremierAddOnPatchResource.Serialization.cs @@ -223,21 +223,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -245,21 +245,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -267,28 +267,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Sku.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Sku}'''"); } else { - builder.AppendLine($" '{Sku}'"); + builder.AppendLine($"'{Sku}'"); } } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -341,21 +341,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Vendor), out propertyOverride); if (Optional.IsDefined(Vendor) || hasPropertyOverride) { - builder.Append(" vendor:"); + builder.Append(" vendor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Vendor.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Vendor}'''"); } else { - builder.AppendLine($" '{Vendor}'"); + builder.AppendLine($"'{Vendor}'"); } } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplacePublisher), out propertyOverride); if (Optional.IsDefined(MarketplacePublisher) || hasPropertyOverride) { - builder.Append(" marketplacePublisher:"); + builder.Append(" marketplacePublisher: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplacePublisher.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplacePublisher}'''"); } else { - builder.AppendLine($" '{MarketplacePublisher}'"); + builder.AppendLine($"'{MarketplacePublisher}'"); } } } @@ -385,21 +385,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplaceOffer), out propertyOverride); if (Optional.IsDefined(MarketplaceOffer) || hasPropertyOverride) { - builder.Append(" marketplaceOffer:"); + builder.Append(" marketplaceOffer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplaceOffer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplaceOffer}'''"); } else { - builder.AppendLine($" '{MarketplaceOffer}'"); + builder.AppendLine($"'{MarketplaceOffer}'"); } } } @@ -409,12 +409,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -435,13 +438,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessSubnet.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessSubnet.Serialization.cs index 971f61c8f82ab..2ff301d8ce31e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessSubnet.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessSubnet.Serialization.cs @@ -119,21 +119,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -141,14 +141,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Key.Value}"); + builder.AppendLine($"{Key.Value}"); } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessVirtualNetwork.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessVirtualNetwork.Serialization.cs index c4200f4ca5716..f13e3020c4383 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessVirtualNetwork.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateAccessVirtualNetwork.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -182,28 +182,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); if (Optional.IsDefined(Key) || hasPropertyOverride) { - builder.Append(" key:"); + builder.Append(" key: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Key.Value}"); + builder.AppendLine($"{Key.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); if (Optional.IsDefined(ResourceId) || hasPropertyOverride) { - builder.Append(" resourceId:"); + builder.Append(" resourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceId.ToString()}'"); + builder.AppendLine($"'{ResourceId.ToString()}'"); } } @@ -212,17 +212,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Subnets.Any() || hasPropertyOverride) { - builder.Append(" subnets:"); + builder.Append(" subnets: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Subnets) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " subnets: "); } builder.AppendLine(" ]"); } @@ -233,12 +233,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -259,13 +262,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionApprovalRequestInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionApprovalRequestInfo.Serialization.cs index 9629b3e9dbadc..84f10f3c81bfc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionApprovalRequestInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionApprovalRequestInfo.Serialization.cs @@ -183,21 +183,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -257,14 +257,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } @@ -273,12 +273,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -299,13 +302,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionState.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionState.Serialization.cs index e4d1b8b247ec2..01008e046540b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionState.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkConnectionState.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) { - builder.Append(" actionsRequired:"); + builder.Append(" actionsRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionsRequired.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionsRequired}'''"); } else { - builder.AppendLine($" '{ActionsRequired}'"); + builder.AppendLine($"'{ActionsRequired}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkResourcesWrapper.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkResourcesWrapper.Serialization.cs index 1079d1eb63ad1..de3d4efeb6683 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkResourcesWrapper.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PrivateLinkResourcesWrapper.Serialization.cs @@ -114,17 +114,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -135,12 +135,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -161,13 +164,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessInfoListResult.Serialization.cs index 757d79f6c4aa0..4b0599dc7d82c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessInfoListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessModuleInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessModuleInfoListResult.Serialization.cs index d80f60d3a01c8..2b76c83b152f1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessModuleInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessModuleInfoListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfo.Serialization.cs index 17c405ab043c1..2ede9d9b72863 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfo.Serialization.cs @@ -316,21 +316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -338,21 +338,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -360,28 +360,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -390,35 +390,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identifier), out propertyOverride); if (Optional.IsDefined(Identifier) || hasPropertyOverride) { - builder.Append(" identifier:"); + builder.Append(" identifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Identifier.Value}"); + builder.AppendLine($"{Identifier.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Href), out propertyOverride); if (Optional.IsDefined(Href) || hasPropertyOverride) { - builder.Append(" href:"); + builder.Append(" href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Href.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Href}'''"); } else { - builder.AppendLine($" '{Href}'"); + builder.AppendLine($"'{Href}'"); } } } @@ -426,21 +426,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Process), out propertyOverride); if (Optional.IsDefined(Process) || hasPropertyOverride) { - builder.Append(" process:"); + builder.Append(" process: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Process.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Process}'''"); } else { - builder.AppendLine($" '{Process}'"); + builder.AppendLine($"'{Process}'"); } } } @@ -448,21 +448,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartAddress), out propertyOverride); if (Optional.IsDefined(StartAddress) || hasPropertyOverride) { - builder.Append(" start_address:"); + builder.Append(" start_address: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StartAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StartAddress}'''"); } else { - builder.AppendLine($" '{StartAddress}'"); + builder.AppendLine($"'{StartAddress}'"); } } } @@ -470,35 +470,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentPriority), out propertyOverride); if (Optional.IsDefined(CurrentPriority) || hasPropertyOverride) { - builder.Append(" current_priority:"); + builder.Append(" current_priority: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {CurrentPriority.Value}"); + builder.AppendLine($"{CurrentPriority.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PriorityLevel), out propertyOverride); if (Optional.IsDefined(PriorityLevel) || hasPropertyOverride) { - builder.Append(" priority_level:"); + builder.Append(" priority_level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PriorityLevel.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PriorityLevel}'''"); } else { - builder.AppendLine($" '{PriorityLevel}'"); + builder.AppendLine($"'{PriorityLevel}'"); } } } @@ -506,50 +506,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BasePriority), out propertyOverride); if (Optional.IsDefined(BasePriority) || hasPropertyOverride) { - builder.Append(" base_priority:"); + builder.Append(" base_priority: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {BasePriority.Value}"); + builder.AppendLine($"{BasePriority.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" start_time:"); + builder.Append(" start_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalProcessorTime), out propertyOverride); if (Optional.IsDefined(TotalProcessorTime) || hasPropertyOverride) { - builder.Append(" total_processor_time:"); + builder.Append(" total_processor_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TotalProcessorTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TotalProcessorTime}'''"); } else { - builder.AppendLine($" '{TotalProcessorTime}'"); + builder.AppendLine($"'{TotalProcessorTime}'"); } } } @@ -557,21 +557,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserProcessorTime), out propertyOverride); if (Optional.IsDefined(UserProcessorTime) || hasPropertyOverride) { - builder.Append(" user_processor_time:"); + builder.Append(" user_processor_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserProcessorTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserProcessorTime}'''"); } else { - builder.AppendLine($" '{UserProcessorTime}'"); + builder.AppendLine($"'{UserProcessorTime}'"); } } } @@ -579,21 +579,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -601,21 +601,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WaitReason), out propertyOverride); if (Optional.IsDefined(WaitReason) || hasPropertyOverride) { - builder.Append(" wait_reason:"); + builder.Append(" wait_reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WaitReason.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WaitReason}'''"); } else { - builder.AppendLine($" '{WaitReason}'"); + builder.AppendLine($"'{WaitReason}'"); } } } @@ -625,12 +625,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -651,13 +654,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfoListResult.Serialization.cs index 8d6bc54b14c9e..35d6ef006a32b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ProcessThreadInfoListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublicCertificateListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublicCertificateListResult.Serialization.cs index 08ec6028e7fec..c8241617b721a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublicCertificateListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublicCertificateListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublishingCredentialsPoliciesListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublishingCredentialsPoliciesListResult.Serialization.cs index 8935ba559ed17..5e5d080dda7fc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublishingCredentialsPoliciesListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/PublishingCredentialsPoliciesListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResult.Serialization.cs index 9929aac0ae243..08953e503ee41 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResult.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SampleUtterance), out propertyOverride); if (Optional.IsDefined(SampleUtterance) || hasPropertyOverride) { - builder.Append(" sampleUtterance:"); + builder.Append(" sampleUtterance: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SampleUtterance, options, 2, false); + AppendChildObject(builder, SampleUtterance, options, 2, false, " sampleUtterance: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Score), out propertyOverride); if (Optional.IsDefined(Score) || hasPropertyOverride) { - builder.Append(" score:"); + builder.Append(" score: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Score.Value.ToString()}'"); + builder.AppendLine($"'{Score.Value.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResults.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResults.Serialization.cs index 2bfbc01310c22..ec0f30dc617b2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResults.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/QueryUtterancesResults.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Query), out propertyOverride); if (Optional.IsDefined(Query) || hasPropertyOverride) { - builder.Append(" query:"); + builder.Append(" query: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Query.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Query}'''"); } else { - builder.AppendLine($" '{Query}'"); + builder.AppendLine($"'{Query}'"); } } } @@ -154,17 +154,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Results.Any() || hasPropertyOverride) { - builder.Append(" results:"); + builder.Append(" results: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Results) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " results: "); } builder.AppendLine(" ]"); } @@ -175,12 +175,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -201,13 +204,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RampUpRule.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RampUpRule.Serialization.cs index aa81aefb4e714..fd8076adff26c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RampUpRule.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RampUpRule.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionHostName), out propertyOverride); if (Optional.IsDefined(ActionHostName) || hasPropertyOverride) { - builder.Append(" actionHostName:"); + builder.Append(" actionHostName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionHostName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionHostName}'''"); } else { - builder.AppendLine($" '{ActionHostName}'"); + builder.AppendLine($"'{ActionHostName}'"); } } } @@ -249,84 +249,84 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReroutePercentage), out propertyOverride); if (Optional.IsDefined(ReroutePercentage) || hasPropertyOverride) { - builder.Append(" reroutePercentage:"); + builder.Append(" reroutePercentage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ReroutePercentage.Value.ToString()}'"); + builder.AppendLine($"'{ReroutePercentage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeStep), out propertyOverride); if (Optional.IsDefined(ChangeStep) || hasPropertyOverride) { - builder.Append(" changeStep:"); + builder.Append(" changeStep: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ChangeStep.Value.ToString()}'"); + builder.AppendLine($"'{ChangeStep.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeIntervalInMinutes), out propertyOverride); if (Optional.IsDefined(ChangeIntervalInMinutes) || hasPropertyOverride) { - builder.Append(" changeIntervalInMinutes:"); + builder.Append(" changeIntervalInMinutes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ChangeIntervalInMinutes.Value}"); + builder.AppendLine($"{ChangeIntervalInMinutes.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinReroutePercentage), out propertyOverride); if (Optional.IsDefined(MinReroutePercentage) || hasPropertyOverride) { - builder.Append(" minReroutePercentage:"); + builder.Append(" minReroutePercentage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinReroutePercentage.Value.ToString()}'"); + builder.AppendLine($"'{MinReroutePercentage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxReroutePercentage), out propertyOverride); if (Optional.IsDefined(MaxReroutePercentage) || hasPropertyOverride) { - builder.Append(" maxReroutePercentage:"); + builder.Append(" maxReroutePercentage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxReroutePercentage.Value.ToString()}'"); + builder.AppendLine($"'{MaxReroutePercentage.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ChangeDecisionCallbackUri), out propertyOverride); if (Optional.IsDefined(ChangeDecisionCallbackUri) || hasPropertyOverride) { - builder.Append(" changeDecisionCallbackUrl:"); + builder.Append(" changeDecisionCallbackUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ChangeDecisionCallbackUri.AbsoluteUri}'"); + builder.AppendLine($"'{ChangeDecisionCallbackUri.AbsoluteUri}'"); } } @@ -334,12 +334,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -360,13 +363,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationAddressInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationAddressInfo.Serialization.cs index 77042b3b88df1..80d9be096f58a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationAddressInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationAddressInfo.Serialization.cs @@ -144,21 +144,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Address1), out propertyOverride); if (Optional.IsDefined(Address1) || hasPropertyOverride) { - builder.Append(" address1:"); + builder.Append(" address1: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Address1.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Address1}'''"); } else { - builder.AppendLine($" '{Address1}'"); + builder.AppendLine($"'{Address1}'"); } } } @@ -166,21 +166,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Address2), out propertyOverride); if (Optional.IsDefined(Address2) || hasPropertyOverride) { - builder.Append(" address2:"); + builder.Append(" address2: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Address2.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Address2}'''"); } else { - builder.AppendLine($" '{Address2}'"); + builder.AppendLine($"'{Address2}'"); } } } @@ -188,21 +188,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(City), out propertyOverride); if (Optional.IsDefined(City) || hasPropertyOverride) { - builder.Append(" city:"); + builder.Append(" city: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (City.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{City}'''"); } else { - builder.AppendLine($" '{City}'"); + builder.AppendLine($"'{City}'"); } } } @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Country), out propertyOverride); if (Optional.IsDefined(Country) || hasPropertyOverride) { - builder.Append(" country:"); + builder.Append(" country: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Country.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Country}'''"); } else { - builder.AppendLine($" '{Country}'"); + builder.AppendLine($"'{Country}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PostalCode), out propertyOverride); if (Optional.IsDefined(PostalCode) || hasPropertyOverride) { - builder.Append(" postalCode:"); + builder.Append(" postalCode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PostalCode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PostalCode}'''"); } else { - builder.AppendLine($" '{PostalCode}'"); + builder.AppendLine($"'{PostalCode}'"); } } } @@ -254,21 +254,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationContactInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationContactInfo.Serialization.cs index e40fb8b5eb6c8..5e38ee8a6a910 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationContactInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RegistrationContactInfo.Serialization.cs @@ -184,35 +184,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AddressMailing), out propertyOverride); if (Optional.IsDefined(AddressMailing) || hasPropertyOverride) { - builder.Append(" addressMailing:"); + builder.Append(" addressMailing: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AddressMailing, options, 2, false); + AppendChildObject(builder, AddressMailing, options, 2, false, " addressMailing: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Email), out propertyOverride); if (Optional.IsDefined(Email) || hasPropertyOverride) { - builder.Append(" email:"); + builder.Append(" email: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Email.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Email}'''"); } else { - builder.AppendLine($" '{Email}'"); + builder.AppendLine($"'{Email}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Fax), out propertyOverride); if (Optional.IsDefined(Fax) || hasPropertyOverride) { - builder.Append(" fax:"); + builder.Append(" fax: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Fax.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Fax}'''"); } else { - builder.AppendLine($" '{Fax}'"); + builder.AppendLine($"'{Fax}'"); } } } @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JobTitle), out propertyOverride); if (Optional.IsDefined(JobTitle) || hasPropertyOverride) { - builder.Append(" jobTitle:"); + builder.Append(" jobTitle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JobTitle.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JobTitle}'''"); } else { - builder.AppendLine($" '{JobTitle}'"); + builder.AppendLine($"'{JobTitle}'"); } } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameFirst), out propertyOverride); if (Optional.IsDefined(NameFirst) || hasPropertyOverride) { - builder.Append(" nameFirst:"); + builder.Append(" nameFirst: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameFirst.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameFirst}'''"); } else { - builder.AppendLine($" '{NameFirst}'"); + builder.AppendLine($"'{NameFirst}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameLast), out propertyOverride); if (Optional.IsDefined(NameLast) || hasPropertyOverride) { - builder.Append(" nameLast:"); + builder.Append(" nameLast: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameLast.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameLast}'''"); } else { - builder.AppendLine($" '{NameLast}'"); + builder.AppendLine($"'{NameLast}'"); } } } @@ -308,21 +308,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameMiddle), out propertyOverride); if (Optional.IsDefined(NameMiddle) || hasPropertyOverride) { - builder.Append(" nameMiddle:"); + builder.Append(" nameMiddle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NameMiddle.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NameMiddle}'''"); } else { - builder.AppendLine($" '{NameMiddle}'"); + builder.AppendLine($"'{NameMiddle}'"); } } } @@ -330,21 +330,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Organization), out propertyOverride); if (Optional.IsDefined(Organization) || hasPropertyOverride) { - builder.Append(" organization:"); + builder.Append(" organization: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Organization.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Organization}'''"); } else { - builder.AppendLine($" '{Organization}'"); + builder.AppendLine($"'{Organization}'"); } } } @@ -352,21 +352,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Phone), out propertyOverride); if (Optional.IsDefined(Phone) || hasPropertyOverride) { - builder.Append(" phone:"); + builder.Append(" phone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Phone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Phone}'''"); } else { - builder.AppendLine($" '{Phone}'"); + builder.AppendLine($"'{Phone}'"); } } } @@ -375,12 +375,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -401,13 +404,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ReissueCertificateOrderContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ReissueCertificateOrderContent.Serialization.cs index bc17ddb7f546a..35e08d52b665b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ReissueCertificateOrderContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ReissueCertificateOrderContent.Serialization.cs @@ -224,21 +224,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -268,28 +268,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -298,49 +298,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); if (Optional.IsDefined(KeySize) || hasPropertyOverride) { - builder.Append(" keySize:"); + builder.Append(" keySize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {KeySize.Value}"); + builder.AppendLine($"{KeySize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DelayExistingRevokeInHours), out propertyOverride); if (Optional.IsDefined(DelayExistingRevokeInHours) || hasPropertyOverride) { - builder.Append(" delayExistingRevokeInHours:"); + builder.Append(" delayExistingRevokeInHours: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DelayExistingRevokeInHours.Value}"); + builder.AppendLine($"{DelayExistingRevokeInHours.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Csr), out propertyOverride); if (Optional.IsDefined(Csr) || hasPropertyOverride) { - builder.Append(" csr:"); + builder.Append(" csr: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Csr.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Csr}'''"); } else { - builder.AppendLine($" '{Csr}'"); + builder.AppendLine($"'{Csr}'"); } } } @@ -348,15 +348,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrivateKeyExternal), out propertyOverride); if (Optional.IsDefined(IsPrivateKeyExternal) || hasPropertyOverride) { - builder.Append(" isPrivateKeyExternal:"); + builder.Append(" isPrivateKeyExternal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrivateKeyExternal.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -365,12 +365,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -391,13 +394,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnection.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnection.Serialization.cs index 4a89d09317997..d7e4503826f22 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnection.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnection.Serialization.cs @@ -249,21 +249,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -271,21 +271,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -293,28 +293,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -323,21 +323,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -345,28 +345,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } @@ -375,14 +375,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPAddresses.Any() || hasPropertyOverride) { - builder.Append(" ipAddresses:"); + builder.Append(" ipAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPAddresses) { if (item == null) @@ -402,12 +402,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -428,13 +431,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnectionListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnectionListResult.Serialization.cs index 82358424f18f3..21c8e18fde70e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RemotePrivateEndpointConnectionListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RenewCertificateOrderContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RenewCertificateOrderContent.Serialization.cs index 6f7d8f8467c05..b2b4138c9ef9c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RenewCertificateOrderContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RenewCertificateOrderContent.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -253,28 +253,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -283,35 +283,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); if (Optional.IsDefined(KeySize) || hasPropertyOverride) { - builder.Append(" keySize:"); + builder.Append(" keySize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {KeySize.Value}"); + builder.AppendLine($"{KeySize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Csr), out propertyOverride); if (Optional.IsDefined(Csr) || hasPropertyOverride) { - builder.Append(" csr:"); + builder.Append(" csr: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Csr.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Csr}'''"); } else { - builder.AppendLine($" '{Csr}'"); + builder.AppendLine($"'{Csr}'"); } } } @@ -319,15 +319,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrivateKeyExternal), out propertyOverride); if (Optional.IsDefined(IsPrivateKeyExternal) || hasPropertyOverride) { - builder.Append(" isPrivateKeyExternal:"); + builder.Append(" isPrivateKeyExternal: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrivateKeyExternal.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RequestsBasedTrigger.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RequestsBasedTrigger.Serialization.cs index e21c7378d9d19..89e35f23cdfbf 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RequestsBasedTrigger.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RequestsBasedTrigger.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeInterval), out propertyOverride); if (Optional.IsDefined(TimeInterval) || hasPropertyOverride) { - builder.Append(" timeInterval:"); + builder.Append(" timeInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeInterval.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeInterval}'''"); } else { - builder.AppendLine($" '{TimeInterval}'"); + builder.AppendLine($"'{TimeInterval}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceHealthMetadataListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceHealthMetadataListResult.Serialization.cs index a3889b1a5ce34..55f17fb857e0d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceHealthMetadataListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceHealthMetadataListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricAvailability.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricAvailability.Serialization.cs index 651a019288fed..e4d86b5e880d3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricAvailability.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricAvailability.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeGrain), out propertyOverride); if (Optional.IsDefined(TimeGrain) || hasPropertyOverride) { - builder.Append(" timeGrain:"); + builder.Append(" timeGrain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeGrain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeGrain}'''"); } else { - builder.AppendLine($" '{TimeGrain}'"); + builder.AppendLine($"'{TimeGrain}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Retention), out propertyOverride); if (Optional.IsDefined(Retention) || hasPropertyOverride) { - builder.Append(" retention:"); + builder.Append(" retention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Retention.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Retention}'''"); } else { - builder.AppendLine($" '{Retention}'"); + builder.AppendLine($"'{Retention}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinition.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinition.Serialization.cs index 0b3069f6fc5a8..051cd51321c33 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinition.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinition.Serialization.cs @@ -257,21 +257,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -279,21 +279,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -301,28 +301,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -331,21 +331,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -353,21 +353,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryAggregationType), out propertyOverride); if (Optional.IsDefined(PrimaryAggregationType) || hasPropertyOverride) { - builder.Append(" primaryAggregationType:"); + builder.Append(" primaryAggregationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrimaryAggregationType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrimaryAggregationType}'''"); } else { - builder.AppendLine($" '{PrimaryAggregationType}'"); + builder.AppendLine($"'{PrimaryAggregationType}'"); } } } @@ -377,17 +377,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MetricAvailabilities.Any() || hasPropertyOverride) { - builder.Append(" metricAvailabilities:"); + builder.Append(" metricAvailabilities: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MetricAvailabilities) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " metricAvailabilities: "); } builder.AppendLine(" ]"); } @@ -397,14 +397,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceUri), out propertyOverride); if (Optional.IsDefined(ResourceUri) || hasPropertyOverride) { - builder.Append(" resourceUri:"); + builder.Append(" resourceUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ResourceUri.AbsoluteUri}'"); + builder.AppendLine($"'{ResourceUri.AbsoluteUri}'"); } } @@ -413,17 +413,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Properties) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -431,12 +431,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -449,12 +449,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -475,13 +478,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinitionListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinitionListResult.Serialization.cs index ae064b73f8497..f48ecac83a43e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinitionListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceMetricDefinitionListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceNameAvailability.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceNameAvailability.Serialization.cs index 42e76ea60aa9f..731c177a5a008 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceNameAvailability.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResourceNameAvailability.Serialization.cs @@ -134,50 +134,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) { - builder.Append(" nameAvailable:"); + builder.Append(" nameAvailable: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsNameAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); if (Optional.IsDefined(Reason) || hasPropertyOverride) { - builder.Append(" reason:"); + builder.Append(" reason: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Reason.Value.ToString()}'"); + builder.AppendLine($"'{Reason.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -186,12 +186,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -212,13 +215,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResponseMessageEnvelopeRemotePrivateEndpointConnection.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResponseMessageEnvelopeRemotePrivateEndpointConnection.Serialization.cs index 64eff7dbed90e..040816601da73 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResponseMessageEnvelopeRemotePrivateEndpointConnection.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ResponseMessageEnvelopeRemotePrivateEndpointConnection.Serialization.cs @@ -296,21 +296,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -318,14 +318,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } @@ -334,17 +334,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -352,12 +352,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -368,63 +368,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Plan), out propertyOverride); if (Optional.IsDefined(Plan) || hasPropertyOverride) { - builder.Append(" plan:"); + builder.Append(" plan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Plan, options, 2, false); + AppendChildObject(builder, Plan, options, 2, false, " plan: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -432,28 +432,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Error, options, 2, false); + AppendChildObject(builder, Error, options, 2, false, " error: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -462,14 +462,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Zones.Any() || hasPropertyOverride) { - builder.Append(" zones:"); + builder.Append(" zones: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Zones) { if (item == null) @@ -495,28 +495,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -524,12 +524,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -550,13 +553,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RestoreRequestInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RestoreRequestInfo.Serialization.cs index dac24be1f0022..abccc6b7ae933 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RestoreRequestInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RestoreRequestInfo.Serialization.cs @@ -328,21 +328,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -350,21 +350,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -372,28 +372,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -402,35 +402,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountUri), out propertyOverride); if (Optional.IsDefined(StorageAccountUri) || hasPropertyOverride) { - builder.Append(" storageAccountUrl:"); + builder.Append(" storageAccountUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountUri.AbsoluteUri}'"); + builder.AppendLine($"'{StorageAccountUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobName), out propertyOverride); if (Optional.IsDefined(BlobName) || hasPropertyOverride) { - builder.Append(" blobName:"); + builder.Append(" blobName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BlobName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BlobName}'''"); } else { - builder.AppendLine($" '{BlobName}'"); + builder.AppendLine($"'{BlobName}'"); } } } @@ -438,36 +438,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanOverwrite), out propertyOverride); if (Optional.IsDefined(CanOverwrite) || hasPropertyOverride) { - builder.Append(" overwrite:"); + builder.Append(" overwrite: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CanOverwrite.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteName), out propertyOverride); if (Optional.IsDefined(SiteName) || hasPropertyOverride) { - builder.Append(" siteName:"); + builder.Append(" siteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteName}'''"); } else { - builder.AppendLine($" '{SiteName}'"); + builder.AppendLine($"'{SiteName}'"); } } } @@ -477,17 +477,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Databases.Any() || hasPropertyOverride) { - builder.Append(" databases:"); + builder.Append(" databases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Databases) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " databases: "); } builder.AppendLine(" ]"); } @@ -497,51 +497,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreConflictingHostNames), out propertyOverride); if (Optional.IsDefined(IgnoreConflictingHostNames) || hasPropertyOverride) { - builder.Append(" ignoreConflictingHostNames:"); + builder.Append(" ignoreConflictingHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IgnoreConflictingHostNames.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreDatabases), out propertyOverride); if (Optional.IsDefined(IgnoreDatabases) || hasPropertyOverride) { - builder.Append(" ignoreDatabases:"); + builder.Append(" ignoreDatabases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IgnoreDatabases.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppServicePlan), out propertyOverride); if (Optional.IsDefined(AppServicePlan) || hasPropertyOverride) { - builder.Append(" appServicePlan:"); + builder.Append(" appServicePlan: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppServicePlan.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppServicePlan}'''"); } else { - builder.AppendLine($" '{AppServicePlan}'"); + builder.AppendLine($"'{AppServicePlan}'"); } } } @@ -549,50 +549,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationType), out propertyOverride); if (Optional.IsDefined(OperationType) || hasPropertyOverride) { - builder.Append(" operationType:"); + builder.Append(" operationType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OperationType.Value.ToSerialString()}'"); + builder.AppendLine($"'{OperationType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdjustConnectionStrings), out propertyOverride); if (Optional.IsDefined(AdjustConnectionStrings) || hasPropertyOverride) { - builder.Append(" adjustConnectionStrings:"); + builder.Append(" adjustConnectionStrings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AdjustConnectionStrings.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironment), out propertyOverride); if (Optional.IsDefined(HostingEnvironment) || hasPropertyOverride) { - builder.Append(" hostingEnvironment:"); + builder.Append(" hostingEnvironment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HostingEnvironment.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HostingEnvironment}'''"); } else { - builder.AppendLine($" '{HostingEnvironment}'"); + builder.AppendLine($"'{HostingEnvironment}'"); } } } @@ -602,12 +602,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -628,13 +631,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RoutingRuleExperiments.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RoutingRuleExperiments.Serialization.cs index 7a86ef15a2d81..9a974677b970f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RoutingRuleExperiments.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/RoutingRuleExperiments.Serialization.cs @@ -121,17 +121,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (RampUpRules.Any() || hasPropertyOverride) { - builder.Append(" rampUpRules:"); + builder.Append(" rampUpRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in RampUpRules) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " rampUpRules: "); } builder.AppendLine(" ]"); } @@ -142,12 +142,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -168,13 +171,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SampleUtterance.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SampleUtterance.Serialization.cs index fd77b5d47bc4d..aa4246de3a918 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SampleUtterance.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SampleUtterance.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Text), out propertyOverride); if (Optional.IsDefined(Text) || hasPropertyOverride) { - builder.Append(" text:"); + builder.Append(" text: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Text.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Text}'''"); } else { - builder.AppendLine($" '{Text}'"); + builder.AppendLine($"'{Text}'"); } } } @@ -165,14 +165,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Links.Any() || hasPropertyOverride) { - builder.Append(" links:"); + builder.Append(" links: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Links) { if (item == null) @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Qid), out propertyOverride); if (Optional.IsDefined(Qid) || hasPropertyOverride) { - builder.Append(" qid:"); + builder.Append(" qid: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Qid.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Qid}'''"); } else { - builder.AppendLine($" '{Qid}'"); + builder.AppendLine($"'{Qid}'"); } } } @@ -221,12 +221,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -247,13 +250,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ServiceSpecification.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ServiceSpecification.Serialization.cs index 83f58f63782f0..8385dba3b05cb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ServiceSpecification.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ServiceSpecification.Serialization.cs @@ -146,17 +146,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MetricSpecifications.Any() || hasPropertyOverride) { - builder.Append(" metricSpecifications:"); + builder.Append(" metricSpecifications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MetricSpecifications) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " metricSpecifications: "); } builder.AppendLine(" ]"); } @@ -168,17 +168,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (LogSpecifications.Any() || hasPropertyOverride) { - builder.Append(" logSpecifications:"); + builder.Append(" logSpecifications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in LogSpecifications) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " logSpecifications: "); } builder.AppendLine(" ]"); } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettings.Serialization.cs index 74a6177498d8a..72c02cc281a33 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettings.Serialization.cs @@ -709,21 +709,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -731,21 +731,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -753,28 +753,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -783,36 +783,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -820,29 +820,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UnauthenticatedClientAction), out propertyOverride); if (Optional.IsDefined(UnauthenticatedClientAction) || hasPropertyOverride) { - builder.Append(" unauthenticatedClientAction:"); + builder.Append(" unauthenticatedClientAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UnauthenticatedClientAction.Value.ToSerialString()}'"); + builder.AppendLine($"'{UnauthenticatedClientAction.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsTokenStoreEnabled), out propertyOverride); if (Optional.IsDefined(IsTokenStoreEnabled) || hasPropertyOverride) { - builder.Append(" tokenStoreEnabled:"); + builder.Append(" tokenStoreEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsTokenStoreEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -851,14 +851,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedExternalRedirectUrls.Any() || hasPropertyOverride) { - builder.Append(" allowedExternalRedirectUrls:"); + builder.Append(" allowedExternalRedirectUrls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedExternalRedirectUrls) { if (item == null) @@ -884,49 +884,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultProvider), out propertyOverride); if (Optional.IsDefined(DefaultProvider) || hasPropertyOverride) { - builder.Append(" defaultProvider:"); + builder.Append(" defaultProvider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DefaultProvider.Value.ToSerialString()}'"); + builder.AppendLine($"'{DefaultProvider.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenRefreshExtensionHours), out propertyOverride); if (Optional.IsDefined(TokenRefreshExtensionHours) || hasPropertyOverride) { - builder.Append(" tokenRefreshExtensionHours:"); + builder.Append(" tokenRefreshExtensionHours: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TokenRefreshExtensionHours.Value.ToString()}'"); + builder.AppendLine($"'{TokenRefreshExtensionHours.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); if (Optional.IsDefined(ClientId) || hasPropertyOverride) { - builder.Append(" clientId:"); + builder.Append(" clientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientId}'''"); } else { - builder.AppendLine($" '{ClientId}'"); + builder.AppendLine($"'{ClientId}'"); } } } @@ -934,21 +934,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecret), out propertyOverride); if (Optional.IsDefined(ClientSecret) || hasPropertyOverride) { - builder.Append(" clientSecret:"); + builder.Append(" clientSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecret}'''"); } else { - builder.AppendLine($" '{ClientSecret}'"); + builder.AppendLine($"'{ClientSecret}'"); } } } @@ -956,21 +956,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" clientSecretSettingName:"); + builder.Append(" clientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{ClientSecretSettingName}'"); + builder.AppendLine($"'{ClientSecretSettingName}'"); } } } @@ -978,21 +978,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateThumbprintString), out propertyOverride); if (Optional.IsDefined(ClientSecretCertificateThumbprintString) || hasPropertyOverride) { - builder.Append(" clientSecretCertificateThumbprint:"); + builder.Append(" clientSecretCertificateThumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientSecretCertificateThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientSecretCertificateThumbprintString}'''"); } else { - builder.AppendLine($" '{ClientSecretCertificateThumbprintString}'"); + builder.AppendLine($"'{ClientSecretCertificateThumbprintString}'"); } } } @@ -1000,21 +1000,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); if (Optional.IsDefined(Issuer) || hasPropertyOverride) { - builder.Append(" issuer:"); + builder.Append(" issuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Issuer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Issuer}'''"); } else { - builder.AppendLine($" '{Issuer}'"); + builder.AppendLine($"'{Issuer}'"); } } } @@ -1022,15 +1022,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidateIssuer), out propertyOverride); if (Optional.IsDefined(ValidateIssuer) || hasPropertyOverride) { - builder.Append(" validateIssuer:"); + builder.Append(" validateIssuer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ValidateIssuer.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -1039,14 +1039,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedAudiences.Any() || hasPropertyOverride) { - builder.Append(" allowedAudiences:"); + builder.Append(" allowedAudiences: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedAudiences) { if (item == null) @@ -1074,14 +1074,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AdditionalLoginParams.Any() || hasPropertyOverride) { - builder.Append(" additionalLoginParams:"); + builder.Append(" additionalLoginParams: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AdditionalLoginParams) { if (item == null) @@ -1107,21 +1107,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AadClaimsAuthorization), out propertyOverride); if (Optional.IsDefined(AadClaimsAuthorization) || hasPropertyOverride) { - builder.Append(" aadClaimsAuthorization:"); + builder.Append(" aadClaimsAuthorization: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AadClaimsAuthorization.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AadClaimsAuthorization}'''"); } else { - builder.AppendLine($" '{AadClaimsAuthorization}'"); + builder.AppendLine($"'{AadClaimsAuthorization}'"); } } } @@ -1129,21 +1129,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GoogleClientId), out propertyOverride); if (Optional.IsDefined(GoogleClientId) || hasPropertyOverride) { - builder.Append(" googleClientId:"); + builder.Append(" googleClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GoogleClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GoogleClientId}'''"); } else { - builder.AppendLine($" '{GoogleClientId}'"); + builder.AppendLine($"'{GoogleClientId}'"); } } } @@ -1151,21 +1151,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GoogleClientSecret), out propertyOverride); if (Optional.IsDefined(GoogleClientSecret) || hasPropertyOverride) { - builder.Append(" googleClientSecret:"); + builder.Append(" googleClientSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GoogleClientSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GoogleClientSecret}'''"); } else { - builder.AppendLine($" '{GoogleClientSecret}'"); + builder.AppendLine($"'{GoogleClientSecret}'"); } } } @@ -1173,21 +1173,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GoogleClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(GoogleClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" googleClientSecretSettingName:"); + builder.Append(" googleClientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GoogleClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GoogleClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{GoogleClientSecretSettingName}'"); + builder.AppendLine($"'{GoogleClientSecretSettingName}'"); } } } @@ -1197,14 +1197,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GoogleOAuthScopes.Any() || hasPropertyOverride) { - builder.Append(" googleOAuthScopes:"); + builder.Append(" googleOAuthScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GoogleOAuthScopes) { if (item == null) @@ -1230,21 +1230,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FacebookAppId), out propertyOverride); if (Optional.IsDefined(FacebookAppId) || hasPropertyOverride) { - builder.Append(" facebookAppId:"); + builder.Append(" facebookAppId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FacebookAppId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FacebookAppId}'''"); } else { - builder.AppendLine($" '{FacebookAppId}'"); + builder.AppendLine($"'{FacebookAppId}'"); } } } @@ -1252,21 +1252,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FacebookAppSecret), out propertyOverride); if (Optional.IsDefined(FacebookAppSecret) || hasPropertyOverride) { - builder.Append(" facebookAppSecret:"); + builder.Append(" facebookAppSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FacebookAppSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FacebookAppSecret}'''"); } else { - builder.AppendLine($" '{FacebookAppSecret}'"); + builder.AppendLine($"'{FacebookAppSecret}'"); } } } @@ -1274,21 +1274,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FacebookAppSecretSettingName), out propertyOverride); if (Optional.IsDefined(FacebookAppSecretSettingName) || hasPropertyOverride) { - builder.Append(" facebookAppSecretSettingName:"); + builder.Append(" facebookAppSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FacebookAppSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FacebookAppSecretSettingName}'''"); } else { - builder.AppendLine($" '{FacebookAppSecretSettingName}'"); + builder.AppendLine($"'{FacebookAppSecretSettingName}'"); } } } @@ -1298,14 +1298,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FacebookOAuthScopes.Any() || hasPropertyOverride) { - builder.Append(" facebookOAuthScopes:"); + builder.Append(" facebookOAuthScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in FacebookOAuthScopes) { if (item == null) @@ -1331,21 +1331,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubClientId), out propertyOverride); if (Optional.IsDefined(GitHubClientId) || hasPropertyOverride) { - builder.Append(" gitHubClientId:"); + builder.Append(" gitHubClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GitHubClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GitHubClientId}'''"); } else { - builder.AppendLine($" '{GitHubClientId}'"); + builder.AppendLine($"'{GitHubClientId}'"); } } } @@ -1353,21 +1353,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubClientSecret), out propertyOverride); if (Optional.IsDefined(GitHubClientSecret) || hasPropertyOverride) { - builder.Append(" gitHubClientSecret:"); + builder.Append(" gitHubClientSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GitHubClientSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GitHubClientSecret}'''"); } else { - builder.AppendLine($" '{GitHubClientSecret}'"); + builder.AppendLine($"'{GitHubClientSecret}'"); } } } @@ -1375,21 +1375,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(GitHubClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" gitHubClientSecretSettingName:"); + builder.Append(" gitHubClientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GitHubClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GitHubClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{GitHubClientSecretSettingName}'"); + builder.AppendLine($"'{GitHubClientSecretSettingName}'"); } } } @@ -1399,14 +1399,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (GitHubOAuthScopes.Any() || hasPropertyOverride) { - builder.Append(" gitHubOAuthScopes:"); + builder.Append(" gitHubOAuthScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in GitHubOAuthScopes) { if (item == null) @@ -1432,21 +1432,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TwitterConsumerKey), out propertyOverride); if (Optional.IsDefined(TwitterConsumerKey) || hasPropertyOverride) { - builder.Append(" twitterConsumerKey:"); + builder.Append(" twitterConsumerKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TwitterConsumerKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TwitterConsumerKey}'''"); } else { - builder.AppendLine($" '{TwitterConsumerKey}'"); + builder.AppendLine($"'{TwitterConsumerKey}'"); } } } @@ -1454,21 +1454,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TwitterConsumerSecret), out propertyOverride); if (Optional.IsDefined(TwitterConsumerSecret) || hasPropertyOverride) { - builder.Append(" twitterConsumerSecret:"); + builder.Append(" twitterConsumerSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TwitterConsumerSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TwitterConsumerSecret}'''"); } else { - builder.AppendLine($" '{TwitterConsumerSecret}'"); + builder.AppendLine($"'{TwitterConsumerSecret}'"); } } } @@ -1476,21 +1476,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TwitterConsumerSecretSettingName), out propertyOverride); if (Optional.IsDefined(TwitterConsumerSecretSettingName) || hasPropertyOverride) { - builder.Append(" twitterConsumerSecretSettingName:"); + builder.Append(" twitterConsumerSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TwitterConsumerSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TwitterConsumerSecretSettingName}'''"); } else { - builder.AppendLine($" '{TwitterConsumerSecretSettingName}'"); + builder.AppendLine($"'{TwitterConsumerSecretSettingName}'"); } } } @@ -1498,21 +1498,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MicrosoftAccountClientId), out propertyOverride); if (Optional.IsDefined(MicrosoftAccountClientId) || hasPropertyOverride) { - builder.Append(" microsoftAccountClientId:"); + builder.Append(" microsoftAccountClientId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MicrosoftAccountClientId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MicrosoftAccountClientId}'''"); } else { - builder.AppendLine($" '{MicrosoftAccountClientId}'"); + builder.AppendLine($"'{MicrosoftAccountClientId}'"); } } } @@ -1520,21 +1520,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MicrosoftAccountClientSecret), out propertyOverride); if (Optional.IsDefined(MicrosoftAccountClientSecret) || hasPropertyOverride) { - builder.Append(" microsoftAccountClientSecret:"); + builder.Append(" microsoftAccountClientSecret: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MicrosoftAccountClientSecret.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MicrosoftAccountClientSecret}'''"); } else { - builder.AppendLine($" '{MicrosoftAccountClientSecret}'"); + builder.AppendLine($"'{MicrosoftAccountClientSecret}'"); } } } @@ -1542,21 +1542,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MicrosoftAccountClientSecretSettingName), out propertyOverride); if (Optional.IsDefined(MicrosoftAccountClientSecretSettingName) || hasPropertyOverride) { - builder.Append(" microsoftAccountClientSecretSettingName:"); + builder.Append(" microsoftAccountClientSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MicrosoftAccountClientSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MicrosoftAccountClientSecretSettingName}'''"); } else { - builder.AppendLine($" '{MicrosoftAccountClientSecretSettingName}'"); + builder.AppendLine($"'{MicrosoftAccountClientSecretSettingName}'"); } } } @@ -1566,14 +1566,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MicrosoftAccountOAuthScopes.Any() || hasPropertyOverride) { - builder.Append(" microsoftAccountOAuthScopes:"); + builder.Append(" microsoftAccountOAuthScopes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MicrosoftAccountOAuthScopes) { if (item == null) @@ -1599,21 +1599,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAuthFromFile), out propertyOverride); if (Optional.IsDefined(IsAuthFromFile) || hasPropertyOverride) { - builder.Append(" isAuthFromFile:"); + builder.Append(" isAuthFromFile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (IsAuthFromFile.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{IsAuthFromFile}'''"); } else { - builder.AppendLine($" '{IsAuthFromFile}'"); + builder.AppendLine($"'{IsAuthFromFile}'"); } } } @@ -1621,21 +1621,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthFilePath), out propertyOverride); if (Optional.IsDefined(AuthFilePath) || hasPropertyOverride) { - builder.Append(" authFilePath:"); + builder.Append(" authFilePath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthFilePath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthFilePath}'''"); } else { - builder.AppendLine($" '{AuthFilePath}'"); + builder.AppendLine($"'{AuthFilePath}'"); } } } @@ -1643,21 +1643,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConfigVersion), out propertyOverride); if (Optional.IsDefined(ConfigVersion) || hasPropertyOverride) { - builder.Append(" configVersion:"); + builder.Append(" configVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConfigVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConfigVersion}'''"); } else { - builder.AppendLine($" '{ConfigVersion}'"); + builder.AppendLine($"'{ConfigVersion}'"); } } } @@ -1667,12 +1667,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1693,13 +1696,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettingsV2.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettingsV2.Serialization.cs index 7943ee6044269..6a4444c650c46 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettingsV2.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteAuthSettingsV2.Serialization.cs @@ -243,21 +243,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -265,21 +265,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -287,28 +287,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -317,70 +317,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); if (Optional.IsDefined(Platform) || hasPropertyOverride) { - builder.Append(" platform:"); + builder.Append(" platform: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Platform, options, 4, false); + AppendChildObject(builder, Platform, options, 4, false, " platform: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GlobalValidation), out propertyOverride); if (Optional.IsDefined(GlobalValidation) || hasPropertyOverride) { - builder.Append(" globalValidation:"); + builder.Append(" globalValidation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GlobalValidation, options, 4, false); + AppendChildObject(builder, GlobalValidation, options, 4, false, " globalValidation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityProviders), out propertyOverride); if (Optional.IsDefined(IdentityProviders) || hasPropertyOverride) { - builder.Append(" identityProviders:"); + builder.Append(" identityProviders: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IdentityProviders, options, 4, false); + AppendChildObject(builder, IdentityProviders, options, 4, false, " identityProviders: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); if (Optional.IsDefined(Login) || hasPropertyOverride) { - builder.Append(" login:"); + builder.Append(" login: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Login, options, 4, false); + AppendChildObject(builder, Login, options, 4, false, " login: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpSettings), out propertyOverride); if (Optional.IsDefined(HttpSettings) || hasPropertyOverride) { - builder.Append(" httpSettings:"); + builder.Append(" httpSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HttpSettings, options, 4, false); + AppendChildObject(builder, HttpSettings, options, 4, false, " httpSettings: "); } } @@ -389,12 +389,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -415,13 +418,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneability.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneability.Serialization.cs index 1eaadcb7133a1..0ce66789aa441 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneability.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneability.Serialization.cs @@ -184,14 +184,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Result), out propertyOverride); if (Optional.IsDefined(Result) || hasPropertyOverride) { - builder.Append(" result:"); + builder.Append(" result: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Result.Value.ToSerialString()}'"); + builder.AppendLine($"'{Result.Value.ToSerialString()}'"); } } @@ -200,17 +200,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlockingFeatures.Any() || hasPropertyOverride) { - builder.Append(" blockingFeatures:"); + builder.Append(" blockingFeatures: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlockingFeatures) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " blockingFeatures: "); } builder.AppendLine(" ]"); } @@ -222,17 +222,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UnsupportedFeatures.Any() || hasPropertyOverride) { - builder.Append(" unsupportedFeatures:"); + builder.Append(" unsupportedFeatures: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UnsupportedFeatures) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " unsupportedFeatures: "); } builder.AppendLine(" ]"); } @@ -244,17 +244,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (BlockingCharacteristics.Any() || hasPropertyOverride) { - builder.Append(" blockingCharacteristics:"); + builder.Append(" blockingCharacteristics: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in BlockingCharacteristics) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " blockingCharacteristics: "); } builder.AppendLine(" ]"); } @@ -265,12 +265,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -291,13 +294,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneabilityCriterion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneabilityCriterion.Serialization.cs index 3f98e50501d17..01fb2e002f256 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneabilityCriterion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteCloneabilityCriterion.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigListResult.Serialization.cs index 4bdc21ea00027..ba0440c0a3fcc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigProperties.Serialization.cs index e609bdba2b6b1..159c876b6785b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigProperties.Serialization.cs @@ -1716,14 +1716,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfWorkers), out propertyOverride); if (Optional.IsDefined(NumberOfWorkers) || hasPropertyOverride) { - builder.Append(" numberOfWorkers:"); + builder.Append(" numberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfWorkers.Value}"); + builder.AppendLine($"{NumberOfWorkers.Value}"); } } @@ -1732,14 +1732,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DefaultDocuments.Any() || hasPropertyOverride) { - builder.Append(" defaultDocuments:"); + builder.Append(" defaultDocuments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DefaultDocuments) { if (item == null) @@ -1765,21 +1765,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetFrameworkVersion), out propertyOverride); if (Optional.IsDefined(NetFrameworkVersion) || hasPropertyOverride) { - builder.Append(" netFrameworkVersion:"); + builder.Append(" netFrameworkVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NetFrameworkVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NetFrameworkVersion}'''"); } else { - builder.AppendLine($" '{NetFrameworkVersion}'"); + builder.AppendLine($"'{NetFrameworkVersion}'"); } } } @@ -1787,21 +1787,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhpVersion), out propertyOverride); if (Optional.IsDefined(PhpVersion) || hasPropertyOverride) { - builder.Append(" phpVersion:"); + builder.Append(" phpVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhpVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhpVersion}'''"); } else { - builder.AppendLine($" '{PhpVersion}'"); + builder.AppendLine($"'{PhpVersion}'"); } } } @@ -1809,21 +1809,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PythonVersion), out propertyOverride); if (Optional.IsDefined(PythonVersion) || hasPropertyOverride) { - builder.Append(" pythonVersion:"); + builder.Append(" pythonVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PythonVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PythonVersion}'''"); } else { - builder.AppendLine($" '{PythonVersion}'"); + builder.AppendLine($"'{PythonVersion}'"); } } } @@ -1831,21 +1831,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NodeVersion), out propertyOverride); if (Optional.IsDefined(NodeVersion) || hasPropertyOverride) { - builder.Append(" nodeVersion:"); + builder.Append(" nodeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NodeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NodeVersion}'''"); } else { - builder.AppendLine($" '{NodeVersion}'"); + builder.AppendLine($"'{NodeVersion}'"); } } } @@ -1853,21 +1853,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PowerShellVersion), out propertyOverride); if (Optional.IsDefined(PowerShellVersion) || hasPropertyOverride) { - builder.Append(" powerShellVersion:"); + builder.Append(" powerShellVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PowerShellVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PowerShellVersion}'''"); } else { - builder.AppendLine($" '{PowerShellVersion}'"); + builder.AppendLine($"'{PowerShellVersion}'"); } } } @@ -1875,21 +1875,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxFxVersion), out propertyOverride); if (Optional.IsDefined(LinuxFxVersion) || hasPropertyOverride) { - builder.Append(" linuxFxVersion:"); + builder.Append(" linuxFxVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LinuxFxVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LinuxFxVersion}'''"); } else { - builder.AppendLine($" '{LinuxFxVersion}'"); + builder.AppendLine($"'{LinuxFxVersion}'"); } } } @@ -1897,21 +1897,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WindowsFxVersion), out propertyOverride); if (Optional.IsDefined(WindowsFxVersion) || hasPropertyOverride) { - builder.Append(" windowsFxVersion:"); + builder.Append(" windowsFxVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WindowsFxVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WindowsFxVersion}'''"); } else { - builder.AppendLine($" '{WindowsFxVersion}'"); + builder.AppendLine($"'{WindowsFxVersion}'"); } } } @@ -1919,66 +1919,66 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRequestTracingEnabled), out propertyOverride); if (Optional.IsDefined(IsRequestTracingEnabled) || hasPropertyOverride) { - builder.Append(" requestTracingEnabled:"); + builder.Append(" requestTracingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRequestTracingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestTracingExpirationOn), out propertyOverride); if (Optional.IsDefined(RequestTracingExpirationOn) || hasPropertyOverride) { - builder.Append(" requestTracingExpirationTime:"); + builder.Append(" requestTracingExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RequestTracingExpirationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRemoteDebuggingEnabled), out propertyOverride); if (Optional.IsDefined(IsRemoteDebuggingEnabled) || hasPropertyOverride) { - builder.Append(" remoteDebuggingEnabled:"); + builder.Append(" remoteDebuggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRemoteDebuggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RemoteDebuggingVersion), out propertyOverride); if (Optional.IsDefined(RemoteDebuggingVersion) || hasPropertyOverride) { - builder.Append(" remoteDebuggingVersion:"); + builder.Append(" remoteDebuggingVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RemoteDebuggingVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RemoteDebuggingVersion}'''"); } else { - builder.AppendLine($" '{RemoteDebuggingVersion}'"); + builder.AppendLine($"'{RemoteDebuggingVersion}'"); } } } @@ -1986,51 +1986,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttpLoggingEnabled), out propertyOverride); if (Optional.IsDefined(IsHttpLoggingEnabled) || hasPropertyOverride) { - builder.Append(" httpLoggingEnabled:"); + builder.Append(" httpLoggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttpLoggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UseManagedIdentityCreds), out propertyOverride); if (Optional.IsDefined(UseManagedIdentityCreds) || hasPropertyOverride) { - builder.Append(" acrUseManagedIdentityCreds:"); + builder.Append(" acrUseManagedIdentityCreds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UseManagedIdentityCreds.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AcrUserManagedIdentityId), out propertyOverride); if (Optional.IsDefined(AcrUserManagedIdentityId) || hasPropertyOverride) { - builder.Append(" acrUserManagedIdentityID:"); + builder.Append(" acrUserManagedIdentityID: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AcrUserManagedIdentityId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AcrUserManagedIdentityId}'''"); } else { - builder.AppendLine($" '{AcrUserManagedIdentityId}'"); + builder.AppendLine($"'{AcrUserManagedIdentityId}'"); } } } @@ -2038,50 +2038,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogsDirectorySizeLimit), out propertyOverride); if (Optional.IsDefined(LogsDirectorySizeLimit) || hasPropertyOverride) { - builder.Append(" logsDirectorySizeLimit:"); + builder.Append(" logsDirectorySizeLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {LogsDirectorySizeLimit.Value}"); + builder.AppendLine($"{LogsDirectorySizeLimit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDetailedErrorLoggingEnabled), out propertyOverride); if (Optional.IsDefined(IsDetailedErrorLoggingEnabled) || hasPropertyOverride) { - builder.Append(" detailedErrorLoggingEnabled:"); + builder.Append(" detailedErrorLoggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDetailedErrorLoggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingUsername), out propertyOverride); if (Optional.IsDefined(PublishingUsername) || hasPropertyOverride) { - builder.Append(" publishingUsername:"); + builder.Append(" publishingUsername: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingUsername.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingUsername}'''"); } else { - builder.AppendLine($" '{PublishingUsername}'"); + builder.AppendLine($"'{PublishingUsername}'"); } } } @@ -2091,17 +2091,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettings.Any() || hasPropertyOverride) { - builder.Append(" appSettings:"); + builder.Append(" appSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AppSettings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " appSettings: "); } builder.AppendLine(" ]"); } @@ -2113,17 +2113,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ConnectionStrings.Any() || hasPropertyOverride) { - builder.Append(" connectionStrings:"); + builder.Append(" connectionStrings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ConnectionStrings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " connectionStrings: "); } builder.AppendLine(" ]"); } @@ -2133,14 +2133,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MachineKey), out propertyOverride); if (Optional.IsDefined(MachineKey) || hasPropertyOverride) { - builder.Append(" machineKey:"); + builder.Append(" machineKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MachineKey, options, 2, false); + AppendChildObject(builder, MachineKey, options, 2, false, " machineKey: "); } } @@ -2149,17 +2149,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HandlerMappings.Any() || hasPropertyOverride) { - builder.Append(" handlerMappings:"); + builder.Append(" handlerMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HandlerMappings) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " handlerMappings: "); } builder.AppendLine(" ]"); } @@ -2169,21 +2169,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DocumentRoot), out propertyOverride); if (Optional.IsDefined(DocumentRoot) || hasPropertyOverride) { - builder.Append(" documentRoot:"); + builder.Append(" documentRoot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DocumentRoot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DocumentRoot}'''"); } else { - builder.AppendLine($" '{DocumentRoot}'"); + builder.AppendLine($"'{DocumentRoot}'"); } } } @@ -2191,80 +2191,80 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScmType), out propertyOverride); if (Optional.IsDefined(ScmType) || hasPropertyOverride) { - builder.Append(" scmType:"); + builder.Append(" scmType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ScmType.Value.ToString()}'"); + builder.AppendLine($"'{ScmType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Use32BitWorkerProcess), out propertyOverride); if (Optional.IsDefined(Use32BitWorkerProcess) || hasPropertyOverride) { - builder.Append(" use32BitWorkerProcess:"); + builder.Append(" use32BitWorkerProcess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Use32BitWorkerProcess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsWebSocketsEnabled), out propertyOverride); if (Optional.IsDefined(IsWebSocketsEnabled) || hasPropertyOverride) { - builder.Append(" webSocketsEnabled:"); + builder.Append(" webSocketsEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsWebSocketsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAlwaysOn), out propertyOverride); if (Optional.IsDefined(IsAlwaysOn) || hasPropertyOverride) { - builder.Append(" alwaysOn:"); + builder.Append(" alwaysOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAlwaysOn.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaVersion), out propertyOverride); if (Optional.IsDefined(JavaVersion) || hasPropertyOverride) { - builder.Append(" javaVersion:"); + builder.Append(" javaVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaVersion}'''"); } else { - builder.AppendLine($" '{JavaVersion}'"); + builder.AppendLine($"'{JavaVersion}'"); } } } @@ -2272,21 +2272,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainer), out propertyOverride); if (Optional.IsDefined(JavaContainer) || hasPropertyOverride) { - builder.Append(" javaContainer:"); + builder.Append(" javaContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainer}'''"); } else { - builder.AppendLine($" '{JavaContainer}'"); + builder.AppendLine($"'{JavaContainer}'"); } } } @@ -2294,21 +2294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainerVersion), out propertyOverride); if (Optional.IsDefined(JavaContainerVersion) || hasPropertyOverride) { - builder.Append(" javaContainerVersion:"); + builder.Append(" javaContainerVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainerVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainerVersion}'''"); } else { - builder.AppendLine($" '{JavaContainerVersion}'"); + builder.AppendLine($"'{JavaContainerVersion}'"); } } } @@ -2316,21 +2316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppCommandLine), out propertyOverride); if (Optional.IsDefined(AppCommandLine) || hasPropertyOverride) { - builder.Append(" appCommandLine:"); + builder.Append(" appCommandLine: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppCommandLine.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppCommandLine}'''"); } else { - builder.AppendLine($" '{AppCommandLine}'"); + builder.AppendLine($"'{AppCommandLine}'"); } } } @@ -2338,14 +2338,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedPipelineMode), out propertyOverride); if (Optional.IsDefined(ManagedPipelineMode) || hasPropertyOverride) { - builder.Append(" managedPipelineMode:"); + builder.Append(" managedPipelineMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedPipelineMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ManagedPipelineMode.Value.ToSerialString()}'"); } } @@ -2354,17 +2354,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualApplications.Any() || hasPropertyOverride) { - builder.Append(" virtualApplications:"); + builder.Append(" virtualApplications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualApplications) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " virtualApplications: "); } builder.AppendLine(" ]"); } @@ -2374,92 +2374,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoadBalancing), out propertyOverride); if (Optional.IsDefined(LoadBalancing) || hasPropertyOverride) { - builder.Append(" loadBalancing:"); + builder.Append(" loadBalancing: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LoadBalancing.Value.ToSerialString()}'"); + builder.AppendLine($"'{LoadBalancing.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Experiments), out propertyOverride); if (Optional.IsDefined(Experiments) || hasPropertyOverride) { - builder.Append(" experiments:"); + builder.Append(" experiments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Experiments, options, 2, false); + AppendChildObject(builder, Experiments, options, 2, false, " experiments: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limits), out propertyOverride); if (Optional.IsDefined(Limits) || hasPropertyOverride) { - builder.Append(" limits:"); + builder.Append(" limits: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Limits, options, 2, false); + AppendChildObject(builder, Limits, options, 2, false, " limits: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoHealEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoHealEnabled) || hasPropertyOverride) { - builder.Append(" autoHealEnabled:"); + builder.Append(" autoHealEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoHealEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoHealRules), out propertyOverride); if (Optional.IsDefined(AutoHealRules) || hasPropertyOverride) { - builder.Append(" autoHealRules:"); + builder.Append(" autoHealRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AutoHealRules, options, 2, false); + AppendChildObject(builder, AutoHealRules, options, 2, false, " autoHealRules: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TracingOptions), out propertyOverride); if (Optional.IsDefined(TracingOptions) || hasPropertyOverride) { - builder.Append(" tracingOptions:"); + builder.Append(" tracingOptions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TracingOptions.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TracingOptions}'''"); } else { - builder.AppendLine($" '{TracingOptions}'"); + builder.AppendLine($"'{TracingOptions}'"); } } } @@ -2467,21 +2467,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetName), out propertyOverride); if (Optional.IsDefined(VnetName) || hasPropertyOverride) { - builder.Append(" vnetName:"); + builder.Append(" vnetName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetName}'''"); } else { - builder.AppendLine($" '{VnetName}'"); + builder.AppendLine($"'{VnetName}'"); } } } @@ -2489,106 +2489,106 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsVnetRouteAllEnabled), out propertyOverride); if (Optional.IsDefined(IsVnetRouteAllEnabled) || hasPropertyOverride) { - builder.Append(" vnetRouteAllEnabled:"); + builder.Append(" vnetRouteAllEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsVnetRouteAllEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetPrivatePortsCount), out propertyOverride); if (Optional.IsDefined(VnetPrivatePortsCount) || hasPropertyOverride) { - builder.Append(" vnetPrivatePortsCount:"); + builder.Append(" vnetPrivatePortsCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VnetPrivatePortsCount.Value}"); + builder.AppendLine($"{VnetPrivatePortsCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 2, false); + AppendChildObject(builder, Cors, options, 2, false, " cors: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Push), out propertyOverride); if (Optional.IsDefined(Push) || hasPropertyOverride) { - builder.Append(" push:"); + builder.Append(" push: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Push, options, 2, false); + AppendChildObject(builder, Push, options, 2, false, " push: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiDefinition), out propertyOverride); if (Optional.IsDefined(ApiDefinition) || hasPropertyOverride) { - builder.Append(" apiDefinition:"); + builder.Append(" apiDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ApiDefinition, options, 2, false); + AppendChildObject(builder, ApiDefinition, options, 2, false, " apiDefinition: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiManagementConfig), out propertyOverride); if (Optional.IsDefined(ApiManagementConfig) || hasPropertyOverride) { - builder.Append(" apiManagementConfig:"); + builder.Append(" apiManagementConfig: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ApiManagementConfig, options, 2, false); + AppendChildObject(builder, ApiManagementConfig, options, 2, false, " apiManagementConfig: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoSwapSlotName), out propertyOverride); if (Optional.IsDefined(AutoSwapSlotName) || hasPropertyOverride) { - builder.Append(" autoSwapSlotName:"); + builder.Append(" autoSwapSlotName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AutoSwapSlotName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AutoSwapSlotName}'''"); } else { - builder.AppendLine($" '{AutoSwapSlotName}'"); + builder.AppendLine($"'{AutoSwapSlotName}'"); } } } @@ -2596,64 +2596,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocalMySqlEnabled), out propertyOverride); if (Optional.IsDefined(IsLocalMySqlEnabled) || hasPropertyOverride) { - builder.Append(" localMySqlEnabled:"); + builder.Append(" localMySqlEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLocalMySqlEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedServiceIdentityId), out propertyOverride); if (Optional.IsDefined(ManagedServiceIdentityId) || hasPropertyOverride) { - builder.Append(" managedServiceIdentityId:"); + builder.Append(" managedServiceIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ManagedServiceIdentityId.Value}"); + builder.AppendLine($"{ManagedServiceIdentityId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(XManagedServiceIdentityId), out propertyOverride); if (Optional.IsDefined(XManagedServiceIdentityId) || hasPropertyOverride) { - builder.Append(" xManagedServiceIdentityId:"); + builder.Append(" xManagedServiceIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {XManagedServiceIdentityId.Value}"); + builder.AppendLine($"{XManagedServiceIdentityId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -2663,17 +2663,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPSecurityRestrictions.Any() || hasPropertyOverride) { - builder.Append(" ipSecurityRestrictions:"); + builder.Append(" ipSecurityRestrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPSecurityRestrictions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " ipSecurityRestrictions: "); } builder.AppendLine(" ]"); } @@ -2685,17 +2685,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ScmIPSecurityRestrictions.Any() || hasPropertyOverride) { - builder.Append(" scmIpSecurityRestrictions:"); + builder.Append(" scmIpSecurityRestrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ScmIPSecurityRestrictions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " scmIpSecurityRestrictions: "); } builder.AppendLine(" ]"); } @@ -2705,121 +2705,121 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowIPSecurityRestrictionsForScmToUseMain), out propertyOverride); if (Optional.IsDefined(AllowIPSecurityRestrictionsForScmToUseMain) || hasPropertyOverride) { - builder.Append(" scmIpSecurityRestrictionsUseMain:"); + builder.Append(" scmIpSecurityRestrictionsUseMain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowIPSecurityRestrictionsForScmToUseMain.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttp20Enabled), out propertyOverride); if (Optional.IsDefined(IsHttp20Enabled) || hasPropertyOverride) { - builder.Append(" http20Enabled:"); + builder.Append(" http20Enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttp20Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinTlsVersion), out propertyOverride); if (Optional.IsDefined(MinTlsVersion) || hasPropertyOverride) { - builder.Append(" minTlsVersion:"); + builder.Append(" minTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{MinTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScmMinTlsVersion), out propertyOverride); if (Optional.IsDefined(ScmMinTlsVersion) || hasPropertyOverride) { - builder.Append(" scmMinTlsVersion:"); + builder.Append(" scmMinTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ScmMinTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{ScmMinTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FtpsState), out propertyOverride); if (Optional.IsDefined(FtpsState) || hasPropertyOverride) { - builder.Append(" ftpsState:"); + builder.Append(" ftpsState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FtpsState.Value.ToString()}'"); + builder.AppendLine($"'{FtpsState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreWarmedInstanceCount), out propertyOverride); if (Optional.IsDefined(PreWarmedInstanceCount) || hasPropertyOverride) { - builder.Append(" preWarmedInstanceCount:"); + builder.Append(" preWarmedInstanceCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PreWarmedInstanceCount.Value}"); + builder.AppendLine($"{PreWarmedInstanceCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAppScaleLimit), out propertyOverride); if (Optional.IsDefined(FunctionAppScaleLimit) || hasPropertyOverride) { - builder.Append(" functionAppScaleLimit:"); + builder.Append(" functionAppScaleLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FunctionAppScaleLimit.Value}"); + builder.AppendLine($"{FunctionAppScaleLimit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HealthCheckPath), out propertyOverride); if (Optional.IsDefined(HealthCheckPath) || hasPropertyOverride) { - builder.Append(" healthCheckPath:"); + builder.Append(" healthCheckPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HealthCheckPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HealthCheckPath}'''"); } else { - builder.AppendLine($" '{HealthCheckPath}'"); + builder.AppendLine($"'{HealthCheckPath}'"); } } } @@ -2827,36 +2827,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsFunctionsRuntimeScaleMonitoringEnabled), out propertyOverride); if (Optional.IsDefined(IsFunctionsRuntimeScaleMonitoringEnabled) || hasPropertyOverride) { - builder.Append(" functionsRuntimeScaleMonitoringEnabled:"); + builder.Append(" functionsRuntimeScaleMonitoringEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsFunctionsRuntimeScaleMonitoringEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebsiteTimeZone), out propertyOverride); if (Optional.IsDefined(WebsiteTimeZone) || hasPropertyOverride) { - builder.Append(" websiteTimeZone:"); + builder.Append(" websiteTimeZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WebsiteTimeZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WebsiteTimeZone}'''"); } else { - builder.AppendLine($" '{WebsiteTimeZone}'"); + builder.AppendLine($"'{WebsiteTimeZone}'"); } } } @@ -2864,14 +2864,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumElasticInstanceCount), out propertyOverride); if (Optional.IsDefined(MinimumElasticInstanceCount) || hasPropertyOverride) { - builder.Append(" minimumElasticInstanceCount:"); + builder.Append(" minimumElasticInstanceCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinimumElasticInstanceCount.Value}"); + builder.AppendLine($"{MinimumElasticInstanceCount.Value}"); } } @@ -2880,18 +2880,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AzureStorageAccounts.Any() || hasPropertyOverride) { - builder.Append(" azureStorageAccounts:"); + builder.Append(" azureStorageAccounts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in AzureStorageAccounts) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 4, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " azureStorageAccounts: "); } builder.AppendLine(" }"); } @@ -2901,21 +2901,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicNetworkAccess.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicNetworkAccess}'''"); } else { - builder.AppendLine($" '{PublicNetworkAccess}'"); + builder.AppendLine($"'{PublicNetworkAccess}'"); } } } @@ -2924,12 +2924,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -2950,13 +2953,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigPropertiesDictionary.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigPropertiesDictionary.Serialization.cs index d24574409cb63..f9bd2b3871a0e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigPropertiesDictionary.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigPropertiesDictionary.Serialization.cs @@ -141,36 +141,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Use32BitWorkerProcess), out propertyOverride); if (Optional.IsDefined(Use32BitWorkerProcess) || hasPropertyOverride) { - builder.Append(" use32BitWorkerProcess:"); + builder.Append(" use32BitWorkerProcess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Use32BitWorkerProcess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxFxVersion), out propertyOverride); if (Optional.IsDefined(LinuxFxVersion) || hasPropertyOverride) { - builder.Append(" linuxFxVersion:"); + builder.Append(" linuxFxVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LinuxFxVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LinuxFxVersion}'''"); } else { - builder.AppendLine($" '{LinuxFxVersion}'"); + builder.AppendLine($"'{LinuxFxVersion}'"); } } } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaVersion), out propertyOverride); if (Optional.IsDefined(JavaVersion) || hasPropertyOverride) { - builder.Append(" javaVersion:"); + builder.Append(" javaVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaVersion}'''"); } else { - builder.AppendLine($" '{JavaVersion}'"); + builder.AppendLine($"'{JavaVersion}'"); } } } @@ -200,21 +200,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PowerShellVersion), out propertyOverride); if (Optional.IsDefined(PowerShellVersion) || hasPropertyOverride) { - builder.Append(" powerShellVersion:"); + builder.Append(" powerShellVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PowerShellVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PowerShellVersion}'''"); } else { - builder.AppendLine($" '{PowerShellVersion}'"); + builder.AppendLine($"'{PowerShellVersion}'"); } } } @@ -223,12 +223,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -249,13 +252,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfo.Serialization.cs index f1df9725e3e01..44f76df1ba79a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfo.Serialization.cs @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,29 +272,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnapshotTakenOn), out propertyOverride); if (Optional.IsDefined(SnapshotTakenOn) || hasPropertyOverride) { - builder.Append(" time:"); + builder.Append(" time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SnapshotTakenOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnapshotId), out propertyOverride); if (Optional.IsDefined(SnapshotId) || hasPropertyOverride) { - builder.Append(" snapshotId:"); + builder.Append(" snapshotId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SnapshotId.Value}"); + builder.AppendLine($"{SnapshotId.Value}"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfoListResult.Serialization.cs index 896cb683fa934..6bd573c4eb8e6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteConfigurationSnapshotInfoListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteExtensionInfoListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteExtensionInfoListResult.Serialization.cs index b7533aa99499c..741c050a5e090 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteExtensionInfoListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteExtensionInfoListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteLimits.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteLimits.Serialization.cs index 7f260f0f5eb45..909238a0dbf6f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteLimits.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteLimits.Serialization.cs @@ -138,42 +138,42 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxPercentageCpu), out propertyOverride); if (Optional.IsDefined(MaxPercentageCpu) || hasPropertyOverride) { - builder.Append(" maxPercentageCpu:"); + builder.Append(" maxPercentageCpu: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxPercentageCpu.Value.ToString()}'"); + builder.AppendLine($"'{MaxPercentageCpu.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxMemoryInMb), out propertyOverride); if (Optional.IsDefined(MaxMemoryInMb) || hasPropertyOverride) { - builder.Append(" maxMemoryInMb:"); + builder.Append(" maxMemoryInMb: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxMemoryInMb.Value.ToString()}'"); + builder.AppendLine($"'{MaxMemoryInMb.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxDiskSizeInMb), out propertyOverride); if (Optional.IsDefined(MaxDiskSizeInMb) || hasPropertyOverride) { - builder.Append(" maxDiskSizeInMb:"); + builder.Append(" maxDiskSizeInMb: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MaxDiskSizeInMb.Value.ToString()}'"); + builder.AppendLine($"'{MaxDiskSizeInMb.Value.ToString()}'"); } } @@ -181,12 +181,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -207,13 +210,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteMachineKey.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteMachineKey.Serialization.cs index fb95f49a4c2de..65d0a5de92583 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteMachineKey.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteMachineKey.Serialization.cs @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); if (Optional.IsDefined(Validation) || hasPropertyOverride) { - builder.Append(" validation:"); + builder.Append(" validation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Validation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Validation}'''"); } else { - builder.AppendLine($" '{Validation}'"); + builder.AppendLine($"'{Validation}'"); } } } @@ -159,21 +159,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidationKey), out propertyOverride); if (Optional.IsDefined(ValidationKey) || hasPropertyOverride) { - builder.Append(" validationKey:"); + builder.Append(" validationKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ValidationKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ValidationKey}'''"); } else { - builder.AppendLine($" '{ValidationKey}'"); + builder.AppendLine($"'{ValidationKey}'"); } } } @@ -181,21 +181,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Decryption), out propertyOverride); if (Optional.IsDefined(Decryption) || hasPropertyOverride) { - builder.Append(" decryption:"); + builder.Append(" decryption: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Decryption.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Decryption}'''"); } else { - builder.AppendLine($" '{Decryption}'"); + builder.AppendLine($"'{Decryption}'"); } } } @@ -203,21 +203,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DecryptionKey), out propertyOverride); if (Optional.IsDefined(DecryptionKey) || hasPropertyOverride) { - builder.Append(" decryptionKey:"); + builder.Append(" decryptionKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DecryptionKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DecryptionKey}'''"); } else { - builder.AppendLine($" '{DecryptionKey}'"); + builder.AppendLine($"'{DecryptionKey}'"); } } } @@ -226,12 +226,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -252,13 +255,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePatchInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePatchInfo.Serialization.cs index 757c7db11ed30..696aef72296ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePatchInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePatchInfo.Serialization.cs @@ -799,21 +799,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -821,35 +821,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -857,28 +857,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -887,21 +887,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -911,14 +911,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNames.Any() || hasPropertyOverride) { - builder.Append(" hostNames:"); + builder.Append(" hostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNames) { if (item == null) @@ -944,21 +944,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositorySiteName), out propertyOverride); if (Optional.IsDefined(RepositorySiteName) || hasPropertyOverride) { - builder.Append(" repositorySiteName:"); + builder.Append(" repositorySiteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositorySiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositorySiteName}'''"); } else { - builder.AppendLine($" '{RepositorySiteName}'"); + builder.AppendLine($"'{RepositorySiteName}'"); } } } @@ -966,29 +966,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UsageState), out propertyOverride); if (Optional.IsDefined(UsageState) || hasPropertyOverride) { - builder.Append(" usageState:"); + builder.Append(" usageState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UsageState.Value.ToSerialString()}'"); + builder.AppendLine($"'{UsageState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -997,14 +997,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EnabledHostNames.Any() || hasPropertyOverride) { - builder.Append(" enabledHostNames:"); + builder.Append(" enabledHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EnabledHostNames) { if (item == null) @@ -1030,14 +1030,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailabilityState), out propertyOverride); if (Optional.IsDefined(AvailabilityState) || hasPropertyOverride) { - builder.Append(" availabilityState:"); + builder.Append(" availabilityState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AvailabilityState.Value.ToSerialString()}'"); + builder.AppendLine($"'{AvailabilityState.Value.ToSerialString()}'"); } } @@ -1046,17 +1046,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNameSslStates.Any() || hasPropertyOverride) { - builder.Append(" hostNameSslStates:"); + builder.Append(" hostNameSslStates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNameSslStates) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " hostNameSslStates: "); } builder.AppendLine(" ]"); } @@ -1066,88 +1066,88 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerFarmId), out propertyOverride); if (Optional.IsDefined(ServerFarmId) || hasPropertyOverride) { - builder.Append(" serverFarmId:"); + builder.Append(" serverFarmId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ServerFarmId.ToString()}'"); + builder.AppendLine($"'{ServerFarmId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReserved), out propertyOverride); if (Optional.IsDefined(IsReserved) || hasPropertyOverride) { - builder.Append(" reserved:"); + builder.Append(" reserved: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReserved.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsXenon), out propertyOverride); if (Optional.IsDefined(IsXenon) || hasPropertyOverride) { - builder.Append(" isXenon:"); + builder.Append(" isXenon: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsXenon.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHyperV), out propertyOverride); if (Optional.IsDefined(IsHyperV) || hasPropertyOverride) { - builder.Append(" hyperV:"); + builder.Append(" hyperV: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHyperV.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) { - builder.Append(" lastModifiedTimeUtc:"); + builder.Append(" lastModifiedTimeUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteConfig), out propertyOverride); if (Optional.IsDefined(SiteConfig) || hasPropertyOverride) { - builder.Append(" siteConfig:"); + builder.Append(" siteConfig: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SiteConfig, options, 4, false); + AppendChildObject(builder, SiteConfig, options, 4, false, " siteConfig: "); } } @@ -1156,14 +1156,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TrafficManagerHostNames.Any() || hasPropertyOverride) { - builder.Append(" trafficManagerHostNames:"); + builder.Append(" trafficManagerHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TrafficManagerHostNames) { if (item == null) @@ -1189,36 +1189,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsScmSiteAlsoStopped), out propertyOverride); if (Optional.IsDefined(IsScmSiteAlsoStopped) || hasPropertyOverride) { - builder.Append(" scmSiteAlsoStopped:"); + builder.Append(" scmSiteAlsoStopped: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsScmSiteAlsoStopped.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetSwapSlot), out propertyOverride); if (Optional.IsDefined(TargetSwapSlot) || hasPropertyOverride) { - builder.Append(" targetSwapSlot:"); + builder.Append(" targetSwapSlot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TargetSwapSlot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TargetSwapSlot}'''"); } else { - builder.AppendLine($" '{TargetSwapSlot}'"); + builder.AppendLine($"'{TargetSwapSlot}'"); } } } @@ -1226,79 +1226,79 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsClientAffinityEnabled), out propertyOverride); if (Optional.IsDefined(IsClientAffinityEnabled) || hasPropertyOverride) { - builder.Append(" clientAffinityEnabled:"); + builder.Append(" clientAffinityEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsClientAffinityEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsClientCertEnabled), out propertyOverride); if (Optional.IsDefined(IsClientCertEnabled) || hasPropertyOverride) { - builder.Append(" clientCertEnabled:"); + builder.Append(" clientCertEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsClientCertEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCertMode), out propertyOverride); if (Optional.IsDefined(ClientCertMode) || hasPropertyOverride) { - builder.Append(" clientCertMode:"); + builder.Append(" clientCertMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ClientCertMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ClientCertMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCertExclusionPaths), out propertyOverride); if (Optional.IsDefined(ClientCertExclusionPaths) || hasPropertyOverride) { - builder.Append(" clientCertExclusionPaths:"); + builder.Append(" clientCertExclusionPaths: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientCertExclusionPaths.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientCertExclusionPaths}'''"); } else { - builder.AppendLine($" '{ClientCertExclusionPaths}'"); + builder.AppendLine($"'{ClientCertExclusionPaths}'"); } } } @@ -1306,36 +1306,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHostNameDisabled), out propertyOverride); if (Optional.IsDefined(IsHostNameDisabled) || hasPropertyOverride) { - builder.Append(" hostNamesDisabled:"); + builder.Append(" hostNamesDisabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHostNameDisabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationId), out propertyOverride); if (Optional.IsDefined(CustomDomainVerificationId) || hasPropertyOverride) { - builder.Append(" customDomainVerificationId:"); + builder.Append(" customDomainVerificationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CustomDomainVerificationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CustomDomainVerificationId}'''"); } else { - builder.AppendLine($" '{CustomDomainVerificationId}'"); + builder.AppendLine($"'{CustomDomainVerificationId}'"); } } } @@ -1343,21 +1343,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutboundIPAddresses), out propertyOverride); if (Optional.IsDefined(OutboundIPAddresses) || hasPropertyOverride) { - builder.Append(" outboundIpAddresses:"); + builder.Append(" outboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OutboundIPAddresses.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OutboundIPAddresses}'''"); } else { - builder.AppendLine($" '{OutboundIPAddresses}'"); + builder.AppendLine($"'{OutboundIPAddresses}'"); } } } @@ -1365,21 +1365,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PossibleOutboundIPAddresses), out propertyOverride); if (Optional.IsDefined(PossibleOutboundIPAddresses) || hasPropertyOverride) { - builder.Append(" possibleOutboundIpAddresses:"); + builder.Append(" possibleOutboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PossibleOutboundIPAddresses.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PossibleOutboundIPAddresses}'''"); } else { - builder.AppendLine($" '{PossibleOutboundIPAddresses}'"); + builder.AppendLine($"'{PossibleOutboundIPAddresses}'"); } } } @@ -1387,92 +1387,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerSize), out propertyOverride); if (Optional.IsDefined(ContainerSize) || hasPropertyOverride) { - builder.Append(" containerSize:"); + builder.Append(" containerSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ContainerSize.Value}"); + builder.AppendLine($"{ContainerSize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DailyMemoryTimeQuota), out propertyOverride); if (Optional.IsDefined(DailyMemoryTimeQuota) || hasPropertyOverride) { - builder.Append(" dailyMemoryTimeQuota:"); + builder.Append(" dailyMemoryTimeQuota: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DailyMemoryTimeQuota.Value}"); + builder.AppendLine($"{DailyMemoryTimeQuota.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuspendOn), out propertyOverride); if (Optional.IsDefined(SuspendOn) || hasPropertyOverride) { - builder.Append(" suspendedTill:"); + builder.Append(" suspendedTill: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SuspendOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxNumberOfWorkers), out propertyOverride); if (Optional.IsDefined(MaxNumberOfWorkers) || hasPropertyOverride) { - builder.Append(" maxNumberOfWorkers:"); + builder.Append(" maxNumberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxNumberOfWorkers.Value}"); + builder.AppendLine($"{MaxNumberOfWorkers.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CloningInfo), out propertyOverride); if (Optional.IsDefined(CloningInfo) || hasPropertyOverride) { - builder.Append(" cloningInfo:"); + builder.Append(" cloningInfo: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CloningInfo, options, 4, false); + AppendChildObject(builder, CloningInfo, options, 4, false, " cloningInfo: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroup), out propertyOverride); if (Optional.IsDefined(ResourceGroup) || hasPropertyOverride) { - builder.Append(" resourceGroup:"); + builder.Append(" resourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroup}'''"); } else { - builder.AppendLine($" '{ResourceGroup}'"); + builder.AppendLine($"'{ResourceGroup}'"); } } } @@ -1480,36 +1480,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefaultContainer), out propertyOverride); if (Optional.IsDefined(IsDefaultContainer) || hasPropertyOverride) { - builder.Append(" isDefaultContainer:"); + builder.Append(" isDefaultContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefaultContainer.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultHostName), out propertyOverride); if (Optional.IsDefined(DefaultHostName) || hasPropertyOverride) { - builder.Append(" defaultHostName:"); + builder.Append(" defaultHostName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultHostName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultHostName}'''"); } else { - builder.AppendLine($" '{DefaultHostName}'"); + builder.AppendLine($"'{DefaultHostName}'"); } } } @@ -1517,93 +1517,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SlotSwapStatus), out propertyOverride); if (Optional.IsDefined(SlotSwapStatus) || hasPropertyOverride) { - builder.Append(" slotSwapStatus:"); + builder.Append(" slotSwapStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SlotSwapStatus, options, 4, false); + AppendChildObject(builder, SlotSwapStatus, options, 4, false, " slotSwapStatus: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttpsOnly), out propertyOverride); if (Optional.IsDefined(IsHttpsOnly) || hasPropertyOverride) { - builder.Append(" httpsOnly:"); + builder.Append(" httpsOnly: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttpsOnly.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RedundancyMode), out propertyOverride); if (Optional.IsDefined(RedundancyMode) || hasPropertyOverride) { - builder.Append(" redundancyMode:"); + builder.Append(" redundancyMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RedundancyMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{RedundancyMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InProgressOperationId), out propertyOverride); if (Optional.IsDefined(InProgressOperationId) || hasPropertyOverride) { - builder.Append(" inProgressOperationId:"); + builder.Append(" inProgressOperationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InProgressOperationId.Value.ToString()}'"); + builder.AppendLine($"'{InProgressOperationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageAccountRequired), out propertyOverride); if (Optional.IsDefined(IsStorageAccountRequired) || hasPropertyOverride) { - builder.Append(" storageAccountRequired:"); + builder.Append(" storageAccountRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageAccountRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -1611,14 +1611,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkSubnetId), out propertyOverride); if (Optional.IsDefined(VirtualNetworkSubnetId) || hasPropertyOverride) { - builder.Append(" virtualNetworkSubnetId:"); + builder.Append(" virtualNetworkSubnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VirtualNetworkSubnetId.ToString()}'"); + builder.AppendLine($"'{VirtualNetworkSubnetId.ToString()}'"); } } @@ -1627,12 +1627,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1653,13 +1656,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePhpErrorLogFlag.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePhpErrorLogFlag.Serialization.cs index ed594ddccbbfc..a6848e6b4eac8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePhpErrorLogFlag.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SitePhpErrorLogFlag.Serialization.cs @@ -212,21 +212,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -234,21 +234,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -256,28 +256,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalLogErrors), out propertyOverride); if (Optional.IsDefined(LocalLogErrors) || hasPropertyOverride) { - builder.Append(" localLogErrors:"); + builder.Append(" localLogErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalLogErrors.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalLogErrors}'''"); } else { - builder.AppendLine($" '{LocalLogErrors}'"); + builder.AppendLine($"'{LocalLogErrors}'"); } } } @@ -308,21 +308,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MasterLogErrors), out propertyOverride); if (Optional.IsDefined(MasterLogErrors) || hasPropertyOverride) { - builder.Append(" masterLogErrors:"); + builder.Append(" masterLogErrors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MasterLogErrors.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MasterLogErrors}'''"); } else { - builder.AppendLine($" '{MasterLogErrors}'"); + builder.AppendLine($"'{MasterLogErrors}'"); } } } @@ -330,21 +330,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalLogErrorsMaxLength), out propertyOverride); if (Optional.IsDefined(LocalLogErrorsMaxLength) || hasPropertyOverride) { - builder.Append(" localLogErrorsMaxLength:"); + builder.Append(" localLogErrorsMaxLength: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalLogErrorsMaxLength.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalLogErrorsMaxLength}'''"); } else { - builder.AppendLine($" '{LocalLogErrorsMaxLength}'"); + builder.AppendLine($"'{LocalLogErrorsMaxLength}'"); } } } @@ -352,21 +352,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MasterLogErrorsMaxLength), out propertyOverride); if (Optional.IsDefined(MasterLogErrorsMaxLength) || hasPropertyOverride) { - builder.Append(" masterLogErrorsMaxLength:"); + builder.Append(" masterLogErrorsMaxLength: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MasterLogErrorsMaxLength.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MasterLogErrorsMaxLength}'''"); } else { - builder.AppendLine($" '{MasterLogErrorsMaxLength}'"); + builder.AppendLine($"'{MasterLogErrorsMaxLength}'"); } } } @@ -376,12 +376,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -402,13 +405,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteSeal.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteSeal.Serialization.cs index cfbfad2b91833..d324b35140a2a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteSeal.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SiteSeal.Serialization.cs @@ -101,21 +101,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Html), out propertyOverride); if (Optional.IsDefined(Html) || hasPropertyOverride) { - builder.Append(" html:"); + builder.Append(" html: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Html.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Html}'''"); } else { - builder.AppendLine($" '{Html}'"); + builder.AppendLine($"'{Html}'"); } } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifference.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifference.Serialization.cs index 538da4df66cee..18a33033f89ac 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifference.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifference.Serialization.cs @@ -245,21 +245,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -267,21 +267,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -289,28 +289,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Level.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Level}'''"); } else { - builder.AppendLine($" '{Level}'"); + builder.AppendLine($"'{Level}'"); } } } @@ -341,21 +341,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SettingType), out propertyOverride); if (Optional.IsDefined(SettingType) || hasPropertyOverride) { - builder.Append(" settingType:"); + builder.Append(" settingType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SettingType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SettingType}'''"); } else { - builder.AppendLine($" '{SettingType}'"); + builder.AppendLine($"'{SettingType}'"); } } } @@ -363,21 +363,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DiffRule), out propertyOverride); if (Optional.IsDefined(DiffRule) || hasPropertyOverride) { - builder.Append(" diffRule:"); + builder.Append(" diffRule: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DiffRule.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DiffRule}'''"); } else { - builder.AppendLine($" '{DiffRule}'"); + builder.AppendLine($"'{DiffRule}'"); } } } @@ -385,21 +385,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SettingName), out propertyOverride); if (Optional.IsDefined(SettingName) || hasPropertyOverride) { - builder.Append(" settingName:"); + builder.Append(" settingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SettingName}'''"); } else { - builder.AppendLine($" '{SettingName}'"); + builder.AppendLine($"'{SettingName}'"); } } } @@ -407,21 +407,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValueInCurrentSlot), out propertyOverride); if (Optional.IsDefined(ValueInCurrentSlot) || hasPropertyOverride) { - builder.Append(" valueInCurrentSlot:"); + builder.Append(" valueInCurrentSlot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ValueInCurrentSlot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ValueInCurrentSlot}'''"); } else { - builder.AppendLine($" '{ValueInCurrentSlot}'"); + builder.AppendLine($"'{ValueInCurrentSlot}'"); } } } @@ -429,21 +429,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValueInTargetSlot), out propertyOverride); if (Optional.IsDefined(ValueInTargetSlot) || hasPropertyOverride) { - builder.Append(" valueInTargetSlot:"); + builder.Append(" valueInTargetSlot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ValueInTargetSlot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ValueInTargetSlot}'''"); } else { - builder.AppendLine($" '{ValueInTargetSlot}'"); + builder.AppendLine($"'{ValueInTargetSlot}'"); } } } @@ -451,21 +451,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -475,12 +475,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -501,13 +504,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifferenceListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifferenceListResult.Serialization.cs index e08e6f7df21d3..c77cc0d7cca0c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifferenceListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotDifferenceListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotSwapStatus.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotSwapStatus.Serialization.cs index e4ac0f258a8c4..5f469ffcabb4a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotSwapStatus.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlotSwapStatus.Serialization.cs @@ -130,36 +130,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimestampUtc), out propertyOverride); if (Optional.IsDefined(TimestampUtc) || hasPropertyOverride) { - builder.Append(" timestampUtc:"); + builder.Append(" timestampUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimestampUtc.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceSlotName), out propertyOverride); if (Optional.IsDefined(SourceSlotName) || hasPropertyOverride) { - builder.Append(" sourceSlotName:"); + builder.Append(" sourceSlotName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceSlotName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceSlotName}'''"); } else { - builder.AppendLine($" '{SourceSlotName}'"); + builder.AppendLine($"'{SourceSlotName}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DestinationSlotName), out propertyOverride); if (Optional.IsDefined(DestinationSlotName) || hasPropertyOverride) { - builder.Append(" destinationSlotName:"); + builder.Append(" destinationSlotName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DestinationSlotName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DestinationSlotName}'''"); } else { - builder.AppendLine($" '{DestinationSlotName}'"); + builder.AppendLine($"'{DestinationSlotName}'"); } } } @@ -190,12 +190,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -216,13 +219,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlowRequestsBasedTrigger.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlowRequestsBasedTrigger.Serialization.cs index 5f83dd210055a..1ef89fc226cac 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlowRequestsBasedTrigger.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SlowRequestsBasedTrigger.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeTaken), out propertyOverride); if (Optional.IsDefined(TimeTaken) || hasPropertyOverride) { - builder.Append(" timeTaken:"); + builder.Append(" timeTaken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeTaken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeTaken}'''"); } else { - builder.AppendLine($" '{TimeTaken}'"); + builder.AppendLine($"'{TimeTaken}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -185,35 +185,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeInterval), out propertyOverride); if (Optional.IsDefined(TimeInterval) || hasPropertyOverride) { - builder.Append(" timeInterval:"); + builder.Append(" timeInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeInterval.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeInterval}'''"); } else { - builder.AppendLine($" '{TimeInterval}'"); + builder.AppendLine($"'{TimeInterval}'"); } } } @@ -222,12 +222,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -248,13 +251,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRecoverySource.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRecoverySource.Serialization.cs index 95b295f28eae5..71b5ccbed71c4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRecoverySource.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRecoverySource.Serialization.cs @@ -123,28 +123,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } @@ -152,12 +152,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -178,13 +181,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRestoreRequest.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRestoreRequest.Serialization.cs index f2f98836f6659..9c4461e2443f8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRestoreRequest.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/SnapshotRestoreRequest.Serialization.cs @@ -254,21 +254,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -276,21 +276,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -298,28 +298,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -328,21 +328,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SnapshotTime), out propertyOverride); if (Optional.IsDefined(SnapshotTime) || hasPropertyOverride) { - builder.Append(" snapshotTime:"); + builder.Append(" snapshotTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SnapshotTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SnapshotTime}'''"); } else { - builder.AppendLine($" '{SnapshotTime}'"); + builder.AppendLine($"'{SnapshotTime}'"); } } } @@ -350,74 +350,74 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoverySource), out propertyOverride); if (Optional.IsDefined(RecoverySource) || hasPropertyOverride) { - builder.Append(" recoverySource:"); + builder.Append(" recoverySource: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, RecoverySource, options, 4, false); + AppendChildObject(builder, RecoverySource, options, 4, false, " recoverySource: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanOverwrite), out propertyOverride); if (Optional.IsDefined(CanOverwrite) || hasPropertyOverride) { - builder.Append(" overwrite:"); + builder.Append(" overwrite: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = CanOverwrite.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoverConfiguration), out propertyOverride); if (Optional.IsDefined(RecoverConfiguration) || hasPropertyOverride) { - builder.Append(" recoverConfiguration:"); + builder.Append(" recoverConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = RecoverConfiguration.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreConflictingHostNames), out propertyOverride); if (Optional.IsDefined(IgnoreConflictingHostNames) || hasPropertyOverride) { - builder.Append(" ignoreConflictingHostNames:"); + builder.Append(" ignoreConflictingHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IgnoreConflictingHostNames.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UseDRSecondary), out propertyOverride); if (Optional.IsDefined(UseDRSecondary) || hasPropertyOverride) { - builder.Append(" useDRSecondary:"); + builder.Append(" useDRSecondary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UseDRSecondary.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -426,12 +426,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -452,13 +455,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMajorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMajorVersion.Serialization.cs index b5ed6b74cf108..5771eb2a7d6f1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMajorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMajorVersion.Serialization.cs @@ -306,21 +306,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayVersion), out propertyOverride); if (Optional.IsDefined(DisplayVersion) || hasPropertyOverride) { - builder.Append(" displayVersion:"); + builder.Append(" displayVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayVersion}'''"); } else { - builder.AppendLine($" '{DisplayVersion}'"); + builder.AppendLine($"'{DisplayVersion}'"); } } } @@ -328,21 +328,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -350,15 +350,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefault), out propertyOverride); if (Optional.IsDefined(IsDefault) || hasPropertyOverride) { - builder.Append(" isDefault:"); + builder.Append(" isDefault: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefault.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -367,17 +367,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MinorVersions.Any() || hasPropertyOverride) { - builder.Append(" minorVersions:"); + builder.Append(" minorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MinorVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " minorVersions: "); } builder.AppendLine(" ]"); } @@ -387,60 +387,60 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsApplicationInsights), out propertyOverride); if (Optional.IsDefined(IsApplicationInsights) || hasPropertyOverride) { - builder.Append(" applicationInsights:"); + builder.Append(" applicationInsights: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsApplicationInsights.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreview), out propertyOverride); if (Optional.IsDefined(IsPreview) || hasPropertyOverride) { - builder.Append(" isPreview:"); + builder.Append(" isPreview: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreview.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeprecated), out propertyOverride); if (Optional.IsDefined(IsDeprecated) || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeprecated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); if (Optional.IsDefined(IsHidden) || hasPropertyOverride) { - builder.Append(" isHidden:"); + builder.Append(" isHidden: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHidden.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -449,23 +449,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettingsDictionary.Any() || hasPropertyOverride) { - builder.Append(" appSettingsDictionary:"); + builder.Append(" appSettingsDictionary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in AppSettingsDictionary) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -477,23 +477,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SiteConfigPropertiesDictionary.Any() || hasPropertyOverride) { - builder.Append(" siteConfigPropertiesDictionary:"); + builder.Append(" siteConfigPropertiesDictionary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in SiteConfigPropertiesDictionary) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -504,12 +504,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -530,13 +533,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMinorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMinorVersion.Serialization.cs index 1eaa9bf9e9f2e..e88450eaca054 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMinorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StackMinorVersion.Serialization.cs @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayVersion), out propertyOverride); if (Optional.IsDefined(DisplayVersion) || hasPropertyOverride) { - builder.Append(" displayVersion:"); + builder.Append(" displayVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayVersion}'''"); } else { - builder.AppendLine($" '{DisplayVersion}'"); + builder.AppendLine($"'{DisplayVersion}'"); } } } @@ -167,21 +167,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -189,30 +189,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefault), out propertyOverride); if (Optional.IsDefined(IsDefault) || hasPropertyOverride) { - builder.Append(" isDefault:"); + builder.Append(" isDefault: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefault.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRemoteDebuggingEnabled), out propertyOverride); if (Optional.IsDefined(IsRemoteDebuggingEnabled) || hasPropertyOverride) { - builder.Append(" isRemoteDebuggingEnabled:"); + builder.Append(" isRemoteDebuggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRemoteDebuggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -220,12 +220,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -246,13 +249,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacity.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacity.Serialization.cs index 634d46a0d05a5..cd1fc96df595b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacity.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacity.Serialization.cs @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -268,49 +268,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailableCapacity), out propertyOverride); if (Optional.IsDefined(AvailableCapacity) || hasPropertyOverride) { - builder.Append(" availableCapacity:"); + builder.Append(" availableCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AvailableCapacity.Value.ToString()}'"); + builder.AppendLine($"'{AvailableCapacity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalCapacity), out propertyOverride); if (Optional.IsDefined(TotalCapacity) || hasPropertyOverride) { - builder.Append(" totalCapacity:"); + builder.Append(" totalCapacity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TotalCapacity.Value.ToString()}'"); + builder.AppendLine($"'{TotalCapacity.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); if (Optional.IsDefined(Unit) || hasPropertyOverride) { - builder.Append(" unit:"); + builder.Append(" unit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Unit.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Unit}'''"); } else { - builder.AppendLine($" '{Unit}'"); + builder.AppendLine($"'{Unit}'"); } } } @@ -318,93 +318,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ComputeMode), out propertyOverride); if (Optional.IsDefined(ComputeMode) || hasPropertyOverride) { - builder.Append(" computeMode:"); + builder.Append(" computeMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ComputeMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ComputeMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerSize), out propertyOverride); if (Optional.IsDefined(WorkerSize) || hasPropertyOverride) { - builder.Append(" workerSize:"); + builder.Append(" workerSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WorkerSize.Value.ToSerialString()}'"); + builder.AppendLine($"'{WorkerSize.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkerSizeId), out propertyOverride); if (Optional.IsDefined(WorkerSizeId) || hasPropertyOverride) { - builder.Append(" workerSizeId:"); + builder.Append(" workerSizeId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {WorkerSizeId.Value}"); + builder.AppendLine($"{WorkerSizeId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExcludeFromCapacityAllocation), out propertyOverride); if (Optional.IsDefined(ExcludeFromCapacityAllocation) || hasPropertyOverride) { - builder.Append(" excludeFromCapacityAllocation:"); + builder.Append(" excludeFromCapacityAllocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ExcludeFromCapacityAllocation.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsApplicableForAllComputeModes), out propertyOverride); if (Optional.IsDefined(IsApplicableForAllComputeModes) || hasPropertyOverride) { - builder.Append(" isApplicableForAllComputeModes:"); + builder.Append(" isApplicableForAllComputeModes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsApplicableForAllComputeModes.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteMode), out propertyOverride); if (Optional.IsDefined(SiteMode) || hasPropertyOverride) { - builder.Append(" siteMode:"); + builder.Append(" siteMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SiteMode.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SiteMode}'''"); } else { - builder.AppendLine($" '{SiteMode}'"); + builder.AppendLine($"'{SiteMode}'"); } } } @@ -412,15 +412,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLinux), out propertyOverride); if (Optional.IsDefined(IsLinux) || hasPropertyOverride) { - builder.Append(" isLinux:"); + builder.Append(" isLinux: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLinux.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -428,12 +428,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -454,13 +457,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacityListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacityListResult.Serialization.cs index f6d66d9613cd0..40b2d3d39a335 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacityListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StampCapacityListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildListResult.Serialization.cs index cbb3bfc505925..efec5b370ad71 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildProperties.Serialization.cs index c754e831ba9c7..5cb818f765c7b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteBuildProperties.Serialization.cs @@ -185,21 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppLocation), out propertyOverride); if (Optional.IsDefined(AppLocation) || hasPropertyOverride) { - builder.Append(" appLocation:"); + builder.Append(" appLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppLocation}'''"); } else { - builder.AppendLine($" '{AppLocation}'"); + builder.AppendLine($"'{AppLocation}'"); } } } @@ -207,21 +207,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiLocation), out propertyOverride); if (Optional.IsDefined(ApiLocation) || hasPropertyOverride) { - builder.Append(" apiLocation:"); + builder.Append(" apiLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApiLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApiLocation}'''"); } else { - builder.AppendLine($" '{ApiLocation}'"); + builder.AppendLine($"'{ApiLocation}'"); } } } @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppArtifactLocation), out propertyOverride); if (Optional.IsDefined(AppArtifactLocation) || hasPropertyOverride) { - builder.Append(" appArtifactLocation:"); + builder.Append(" appArtifactLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppArtifactLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppArtifactLocation}'''"); } else { - builder.AppendLine($" '{AppArtifactLocation}'"); + builder.AppendLine($"'{AppArtifactLocation}'"); } } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutputLocation), out propertyOverride); if (Optional.IsDefined(OutputLocation) || hasPropertyOverride) { - builder.Append(" outputLocation:"); + builder.Append(" outputLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OutputLocation.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OutputLocation}'''"); } else { - builder.AppendLine($" '{OutputLocation}'"); + builder.AppendLine($"'{OutputLocation}'"); } } } @@ -273,21 +273,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppBuildCommand), out propertyOverride); if (Optional.IsDefined(AppBuildCommand) || hasPropertyOverride) { - builder.Append(" appBuildCommand:"); + builder.Append(" appBuildCommand: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppBuildCommand.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppBuildCommand}'''"); } else { - builder.AppendLine($" '{AppBuildCommand}'"); + builder.AppendLine($"'{AppBuildCommand}'"); } } } @@ -295,21 +295,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiBuildCommand), out propertyOverride); if (Optional.IsDefined(ApiBuildCommand) || hasPropertyOverride) { - builder.Append(" apiBuildCommand:"); + builder.Append(" apiBuildCommand: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ApiBuildCommand.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ApiBuildCommand}'''"); } else { - builder.AppendLine($" '{ApiBuildCommand}'"); + builder.AppendLine($"'{ApiBuildCommand}'"); } } } @@ -317,36 +317,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkipGithubActionWorkflowGeneration), out propertyOverride); if (Optional.IsDefined(SkipGithubActionWorkflowGeneration) || hasPropertyOverride) { - builder.Append(" skipGithubActionWorkflowGeneration:"); + builder.Append(" skipGithubActionWorkflowGeneration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SkipGithubActionWorkflowGeneration.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GithubActionSecretNameOverride), out propertyOverride); if (Optional.IsDefined(GithubActionSecretNameOverride) || hasPropertyOverride) { - builder.Append(" githubActionSecretNameOverride:"); + builder.Append(" githubActionSecretNameOverride: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (GithubActionSecretNameOverride.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{GithubActionSecretNameOverride}'''"); } else { - builder.AppendLine($" '{GithubActionSecretNameOverride}'"); + builder.AppendLine($"'{GithubActionSecretNameOverride}'"); } } } @@ -355,12 +355,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -381,13 +384,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainContent.Serialization.cs index 92cee298a347d..b90122c97177b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainContent.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidationMethod), out propertyOverride); if (Optional.IsDefined(ValidationMethod) || hasPropertyOverride) { - builder.Append(" validationMethod:"); + builder.Append(" validationMethod: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ValidationMethod.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ValidationMethod}'''"); } else { - builder.AppendLine($" '{ValidationMethod}'"); + builder.AppendLine($"'{ValidationMethod}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainOverviewListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainOverviewListResult.Serialization.cs index bb9be2c2a4124..f1904d965fa78 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainOverviewListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteCustomDomainOverviewListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverview.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverview.Serialization.cs index 8a798395d64d9..6e2b610a247f5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverview.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverview.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionName), out propertyOverride); if (Optional.IsDefined(FunctionName) || hasPropertyOverride) { - builder.Append(" functionName:"); + builder.Append(" functionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FunctionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FunctionName}'''"); } else { - builder.AppendLine($" '{FunctionName}'"); + builder.AppendLine($"'{FunctionName}'"); } } } @@ -290,14 +290,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerType), out propertyOverride); if (Optional.IsDefined(TriggerType) || hasPropertyOverride) { - builder.Append(" triggerType:"); + builder.Append(" triggerType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TriggerType.Value.ToString()}'"); + builder.AppendLine($"'{TriggerType.Value.ToString()}'"); } } @@ -306,12 +306,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -332,13 +335,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverviewListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverviewListResult.Serialization.cs index a7ddd2a4d76fb..2bc7d3be2a404 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverviewListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteFunctionOverviewListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteListResult.Serialization.cs index ed2deb4a295e5..71cea4956bf69 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitePatch.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitePatch.Serialization.cs index 1988d23d5498a..604efc938ae36 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitePatch.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitePatch.Serialization.cs @@ -386,21 +386,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -408,21 +408,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -430,28 +430,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -460,21 +460,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultHostname), out propertyOverride); if (Optional.IsDefined(DefaultHostname) || hasPropertyOverride) { - builder.Append(" defaultHostname:"); + builder.Append(" defaultHostname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultHostname.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultHostname}'''"); } else { - builder.AppendLine($" '{DefaultHostname}'"); + builder.AppendLine($"'{DefaultHostname}'"); } } } @@ -482,35 +482,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryUri), out propertyOverride); if (Optional.IsDefined(RepositoryUri) || hasPropertyOverride) { - builder.Append(" repositoryUrl:"); + builder.Append(" repositoryUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RepositoryUri.AbsoluteUri}'"); + builder.AppendLine($"'{RepositoryUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); if (Optional.IsDefined(Branch) || hasPropertyOverride) { - builder.Append(" branch:"); + builder.Append(" branch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Branch.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Branch}'''"); } else { - builder.AppendLine($" '{Branch}'"); + builder.AppendLine($"'{Branch}'"); } } } @@ -520,14 +520,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CustomDomains.Any() || hasPropertyOverride) { - builder.Append(" customDomains:"); + builder.Append(" customDomains: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CustomDomains) { if (item == null) @@ -553,21 +553,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryToken), out propertyOverride); if (Optional.IsDefined(RepositoryToken) || hasPropertyOverride) { - builder.Append(" repositoryToken:"); + builder.Append(" repositoryToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositoryToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositoryToken}'''"); } else { - builder.AppendLine($" '{RepositoryToken}'"); + builder.AppendLine($"'{RepositoryToken}'"); } } } @@ -575,14 +575,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BuildProperties), out propertyOverride); if (Optional.IsDefined(BuildProperties) || hasPropertyOverride) { - builder.Append(" buildProperties:"); + builder.Append(" buildProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BuildProperties, options, 4, false); + AppendChildObject(builder, BuildProperties, options, 4, false, " buildProperties: "); } } @@ -591,17 +591,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -611,64 +611,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StagingEnvironmentPolicy), out propertyOverride); if (Optional.IsDefined(StagingEnvironmentPolicy) || hasPropertyOverride) { - builder.Append(" stagingEnvironmentPolicy:"); + builder.Append(" stagingEnvironmentPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StagingEnvironmentPolicy.Value.ToSerialString()}'"); + builder.AppendLine($"'{StagingEnvironmentPolicy.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowConfigFileUpdates), out propertyOverride); if (Optional.IsDefined(AllowConfigFileUpdates) || hasPropertyOverride) { - builder.Append(" allowConfigFileUpdates:"); + builder.Append(" allowConfigFileUpdates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowConfigFileUpdates.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateProperties), out propertyOverride); if (Optional.IsDefined(TemplateProperties) || hasPropertyOverride) { - builder.Append(" templateProperties:"); + builder.Append(" templateProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TemplateProperties, options, 4, false); + AppendChildObject(builder, TemplateProperties, options, 4, false, " templateProperties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentDistributionEndpoint), out propertyOverride); if (Optional.IsDefined(ContentDistributionEndpoint) || hasPropertyOverride) { - builder.Append(" contentDistributionEndpoint:"); + builder.Append(" contentDistributionEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentDistributionEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentDistributionEndpoint}'''"); } else { - builder.AppendLine($" '{ContentDistributionEndpoint}'"); + builder.AppendLine($"'{ContentDistributionEndpoint}'"); } } } @@ -676,21 +676,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -700,17 +700,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserProvidedFunctionApps.Any() || hasPropertyOverride) { - builder.Append(" userProvidedFunctionApps:"); + builder.Append(" userProvidedFunctionApps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserProvidedFunctionApps) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " userProvidedFunctionApps: "); } builder.AppendLine(" ]"); } @@ -720,21 +720,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -744,12 +744,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -770,13 +773,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteResetContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteResetContent.Serialization.cs index 4a00097007893..a2f7291d9e230 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteResetContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteResetContent.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryToken), out propertyOverride); if (Optional.IsDefined(RepositoryToken) || hasPropertyOverride) { - builder.Append(" repositoryToken:"); + builder.Append(" repositoryToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositoryToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositoryToken}'''"); } else { - builder.AppendLine($" '{RepositoryToken}'"); + builder.AppendLine($"'{RepositoryToken}'"); } } } @@ -290,15 +290,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShouldUpdateRepository), out propertyOverride); if (Optional.IsDefined(ShouldUpdateRepository) || hasPropertyOverride) { - builder.Append(" shouldUpdateRepository:"); + builder.Append(" shouldUpdateRepository: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ShouldUpdateRepository.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -307,12 +307,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -333,13 +336,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteStringList.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteStringList.Serialization.cs index 10ad029f3c1b0..31e8ace4c52eb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteStringList.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteStringList.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -203,14 +203,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Properties.Any() || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Properties) { if (item == null) @@ -236,21 +236,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -258,28 +258,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -287,12 +287,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -313,13 +316,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteTemplate.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteTemplate.Serialization.cs index 823d3a39d988d..0aad75e13ebe2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteTemplate.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteTemplate.Serialization.cs @@ -156,35 +156,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateRepositoryUri), out propertyOverride); if (Optional.IsDefined(TemplateRepositoryUri) || hasPropertyOverride) { - builder.Append(" templateRepositoryUrl:"); + builder.Append(" templateRepositoryUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{TemplateRepositoryUri.AbsoluteUri}'"); + builder.AppendLine($"'{TemplateRepositoryUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Owner), out propertyOverride); if (Optional.IsDefined(Owner) || hasPropertyOverride) { - builder.Append(" owner:"); + builder.Append(" owner: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Owner.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Owner}'''"); } else { - builder.AppendLine($" '{Owner}'"); + builder.AppendLine($"'{Owner}'"); } } } @@ -192,21 +192,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryName), out propertyOverride); if (Optional.IsDefined(RepositoryName) || hasPropertyOverride) { - builder.Append(" repositoryName:"); + builder.Append(" repositoryName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositoryName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositoryName}'''"); } else { - builder.AppendLine($" '{RepositoryName}'"); + builder.AppendLine($"'{RepositoryName}'"); } } } @@ -214,21 +214,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -236,15 +236,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPrivate), out propertyOverride); if (Optional.IsDefined(IsPrivate) || hasPropertyOverride) { - builder.Append(" isPrivate:"); + builder.Append(" isPrivate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPrivate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -252,12 +252,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -278,13 +281,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUser.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUser.Serialization.cs index 315b8b502323b..2c764518148fd 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUser.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUser.Serialization.cs @@ -212,21 +212,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -234,21 +234,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -256,28 +256,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -308,21 +308,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserId), out propertyOverride); if (Optional.IsDefined(UserId) || hasPropertyOverride) { - builder.Append(" userId:"); + builder.Append(" userId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserId}'''"); } else { - builder.AppendLine($" '{UserId}'"); + builder.AppendLine($"'{UserId}'"); } } } @@ -330,21 +330,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -352,21 +352,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Roles), out propertyOverride); if (Optional.IsDefined(Roles) || hasPropertyOverride) { - builder.Append(" roles:"); + builder.Append(" roles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Roles.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Roles}'''"); } else { - builder.AppendLine($" '{Roles}'"); + builder.AppendLine($"'{Roles}'"); } } } @@ -376,12 +376,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -402,13 +405,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationContent.Serialization.cs index c451360c6331e..69c80cc6731a6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationContent.Serialization.cs @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -249,21 +249,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -271,28 +271,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Domain), out propertyOverride); if (Optional.IsDefined(Domain) || hasPropertyOverride) { - builder.Append(" domain:"); + builder.Append(" domain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Domain.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Domain}'''"); } else { - builder.AppendLine($" '{Domain}'"); + builder.AppendLine($"'{Domain}'"); } } } @@ -323,21 +323,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -345,21 +345,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserDetails), out propertyOverride); if (Optional.IsDefined(UserDetails) || hasPropertyOverride) { - builder.Append(" userDetails:"); + builder.Append(" userDetails: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserDetails.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserDetails}'''"); } else { - builder.AppendLine($" '{UserDetails}'"); + builder.AppendLine($"'{UserDetails}'"); } } } @@ -367,21 +367,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Roles), out propertyOverride); if (Optional.IsDefined(Roles) || hasPropertyOverride) { - builder.Append(" roles:"); + builder.Append(" roles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Roles.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Roles}'''"); } else { - builder.AppendLine($" '{Roles}'"); + builder.AppendLine($"'{Roles}'"); } } } @@ -389,14 +389,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumHoursToExpiration), out propertyOverride); if (Optional.IsDefined(NumHoursToExpiration) || hasPropertyOverride) { - builder.Append(" numHoursToExpiration:"); + builder.Append(" numHoursToExpiration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumHoursToExpiration.Value}"); + builder.AppendLine($"{NumHoursToExpiration.Value}"); } } @@ -405,12 +405,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -431,13 +434,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationResult.Serialization.cs index fb28826886467..a78fc5d401a0f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserInvitationResult.Serialization.cs @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,29 +272,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpiresOn), out propertyOverride); if (Optional.IsDefined(ExpiresOn) || hasPropertyOverride) { - builder.Append(" expiresOn:"); + builder.Append(" expiresOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(ExpiresOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InvitationUri), out propertyOverride); if (Optional.IsDefined(InvitationUri) || hasPropertyOverride) { - builder.Append(" invitationUrl:"); + builder.Append(" invitationUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InvitationUri.AbsoluteUri}'"); + builder.AppendLine($"'{InvitationUri.AbsoluteUri}'"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserListResult.Serialization.cs index eff0c8821bc01..c046f537464b2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserProvidedFunctionAppsListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserProvidedFunctionAppsListResult.Serialization.cs index b85df48b31e18..d701d527b00dd 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserProvidedFunctionAppsListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteUserProvidedFunctionAppsListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteZipDeployment.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteZipDeployment.Serialization.cs index a35b5049a5786..275d21eb71476 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteZipDeployment.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSiteZipDeployment.Serialization.cs @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -275,28 +275,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -305,49 +305,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppZipUri), out propertyOverride); if (Optional.IsDefined(AppZipUri) || hasPropertyOverride) { - builder.Append(" appZipUrl:"); + builder.Append(" appZipUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AppZipUri.AbsoluteUri}'"); + builder.AppendLine($"'{AppZipUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiZipUri), out propertyOverride); if (Optional.IsDefined(ApiZipUri) || hasPropertyOverride) { - builder.Append(" apiZipUrl:"); + builder.Append(" apiZipUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ApiZipUri.AbsoluteUri}'"); + builder.AppendLine($"'{ApiZipUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentTitle), out propertyOverride); if (Optional.IsDefined(DeploymentTitle) || hasPropertyOverride) { - builder.Append(" deploymentTitle:"); + builder.Append(" deploymentTitle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeploymentTitle.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeploymentTitle}'''"); } else { - builder.AppendLine($" '{DeploymentTitle}'"); + builder.AppendLine($"'{DeploymentTitle}'"); } } } @@ -355,21 +355,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -377,21 +377,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionLanguage), out propertyOverride); if (Optional.IsDefined(FunctionLanguage) || hasPropertyOverride) { - builder.Append(" functionLanguage:"); + builder.Append(" functionLanguage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FunctionLanguage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FunctionLanguage}'''"); } else { - builder.AppendLine($" '{FunctionLanguage}'"); + builder.AppendLine($"'{FunctionLanguage}'"); } } } @@ -401,12 +401,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -427,13 +430,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreview.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreview.Serialization.cs index fd034d591450f..cb22eff5f7015 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreview.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreview.Serialization.cs @@ -190,21 +190,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -212,21 +212,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -234,28 +234,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Contents), out propertyOverride); if (Optional.IsDefined(Contents) || hasPropertyOverride) { - builder.Append(" contents:"); + builder.Append(" contents: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Contents.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Contents}'''"); } else { - builder.AppendLine($" '{Contents}'"); + builder.AppendLine($"'{Contents}'"); } } } @@ -310,12 +310,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -336,13 +339,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreviewContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreviewContent.Serialization.cs index b036e8d01df08..5836595917169 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreviewContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StaticSitesWorkflowPreviewContent.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -253,28 +253,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -283,35 +283,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryUri), out propertyOverride); if (Optional.IsDefined(RepositoryUri) || hasPropertyOverride) { - builder.Append(" repositoryUrl:"); + builder.Append(" repositoryUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RepositoryUri.AbsoluteUri}'"); + builder.AppendLine($"'{RepositoryUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); if (Optional.IsDefined(Branch) || hasPropertyOverride) { - builder.Append(" branch:"); + builder.Append(" branch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Branch.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Branch}'''"); } else { - builder.AppendLine($" '{Branch}'"); + builder.AppendLine($"'{Branch}'"); } } } @@ -319,14 +319,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BuildProperties), out propertyOverride); if (Optional.IsDefined(BuildProperties) || hasPropertyOverride) { - builder.Append(" buildProperties:"); + builder.Append(" buildProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BuildProperties, options, 4, false); + AppendChildObject(builder, BuildProperties, options, 4, false, " buildProperties: "); } } @@ -335,12 +335,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -361,13 +364,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesBasedTrigger.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesBasedTrigger.Serialization.cs index ef80662297a4b..5d84a62146c8a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesBasedTrigger.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesBasedTrigger.Serialization.cs @@ -175,77 +175,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Status.Value}"); + builder.AppendLine($"{Status.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubStatus), out propertyOverride); if (Optional.IsDefined(SubStatus) || hasPropertyOverride) { - builder.Append(" subStatus:"); + builder.Append(" subStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {SubStatus.Value}"); + builder.AppendLine($"{SubStatus.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Win32Status), out propertyOverride); if (Optional.IsDefined(Win32Status) || hasPropertyOverride) { - builder.Append(" win32Status:"); + builder.Append(" win32Status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Win32Status.Value}"); + builder.AppendLine($"{Win32Status.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeInterval), out propertyOverride); if (Optional.IsDefined(TimeInterval) || hasPropertyOverride) { - builder.Append(" timeInterval:"); + builder.Append(" timeInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeInterval.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeInterval}'''"); } else { - builder.AppendLine($" '{TimeInterval}'"); + builder.AppendLine($"'{TimeInterval}'"); } } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -276,12 +276,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -302,13 +305,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesRangeBasedTrigger.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesRangeBasedTrigger.Serialization.cs index b418f65b1eb50..4892aa1da6c79 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesRangeBasedTrigger.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StatusCodesRangeBasedTrigger.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusCodes), out propertyOverride); if (Optional.IsDefined(StatusCodes) || hasPropertyOverride) { - builder.Append(" statusCodes:"); + builder.Append(" statusCodes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (StatusCodes.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{StatusCodes}'''"); } else { - builder.AppendLine($" '{StatusCodes}'"); + builder.AppendLine($"'{StatusCodes}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -185,35 +185,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); if (Optional.IsDefined(Count) || hasPropertyOverride) { - builder.Append(" count:"); + builder.Append(" count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Count.Value}"); + builder.AppendLine($"{Count.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeInterval), out propertyOverride); if (Optional.IsDefined(TimeInterval) || hasPropertyOverride) { - builder.Append(" timeInterval:"); + builder.Append(" timeInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeInterval.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeInterval}'''"); } else { - builder.AppendLine($" '{TimeInterval}'"); + builder.AppendLine($"'{TimeInterval}'"); } } } @@ -222,12 +222,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -248,13 +251,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationContent.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationContent.Serialization.cs index 68ced82d92355..aacaf3860a79c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationContent.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationContent.Serialization.cs @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -264,28 +264,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -294,21 +294,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzurefilesConnectionString), out propertyOverride); if (Optional.IsDefined(AzurefilesConnectionString) || hasPropertyOverride) { - builder.Append(" azurefilesConnectionString:"); + builder.Append(" azurefilesConnectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzurefilesConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzurefilesConnectionString}'''"); } else { - builder.AppendLine($" '{AzurefilesConnectionString}'"); + builder.AppendLine($"'{AzurefilesConnectionString}'"); } } } @@ -316,21 +316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzurefilesShare), out propertyOverride); if (Optional.IsDefined(AzurefilesShare) || hasPropertyOverride) { - builder.Append(" azurefilesShare:"); + builder.Append(" azurefilesShare: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AzurefilesShare.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AzurefilesShare}'''"); } else { - builder.AppendLine($" '{AzurefilesShare}'"); + builder.AppendLine($"'{AzurefilesShare}'"); } } } @@ -338,30 +338,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SwitchSiteAfterMigration), out propertyOverride); if (Optional.IsDefined(SwitchSiteAfterMigration) || hasPropertyOverride) { - builder.Append(" switchSiteAfterMigration:"); + builder.Append(" switchSiteAfterMigration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SwitchSiteAfterMigration.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlockWriteAccessToSite), out propertyOverride); if (Optional.IsDefined(BlockWriteAccessToSite) || hasPropertyOverride) { - builder.Append(" blockWriteAccessToSite:"); + builder.Append(" blockWriteAccessToSite: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = BlockWriteAccessToSite.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -370,12 +370,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -396,13 +399,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationResult.Serialization.cs index b84c491575085..f8a842e6cb692 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/StorageMigrationResult.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationId), out propertyOverride); if (Optional.IsDefined(OperationId) || hasPropertyOverride) { - builder.Append(" operationId:"); + builder.Append(" operationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OperationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OperationId}'''"); } else { - builder.AppendLine($" '{OperationId}'"); + builder.AppendLine($"'{OperationId}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreement.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreement.Serialization.cs index bf562cf083872..542604597dd7f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreement.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreement.Serialization.cs @@ -132,21 +132,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgreementKey), out propertyOverride); if (Optional.IsDefined(AgreementKey) || hasPropertyOverride) { - builder.Append(" agreementKey:"); + builder.Append(" agreementKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AgreementKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AgreementKey}'''"); } else { - builder.AppendLine($" '{AgreementKey}'"); + builder.AppendLine($"'{AgreementKey}'"); } } } @@ -154,21 +154,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); if (Optional.IsDefined(Title) || hasPropertyOverride) { - builder.Append(" title:"); + builder.Append(" title: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Title.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Title}'''"); } else { - builder.AppendLine($" '{Title}'"); + builder.AppendLine($"'{Title}'"); } } } @@ -176,21 +176,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Content), out propertyOverride); if (Optional.IsDefined(Content) || hasPropertyOverride) { - builder.Append(" content:"); + builder.Append(" content: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Content.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Content}'''"); } else { - builder.AppendLine($" '{Content}'"); + builder.AppendLine($"'{Content}'"); } } } @@ -198,14 +198,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } @@ -213,12 +213,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -239,13 +242,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreementListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreementListResult.Serialization.cs index 632578ce63bde..9776877627c39 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreementListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TldLegalAgreementListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TopLevelDomainListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TopLevelDomainListResult.Serialization.cs index b842668a0875d..ecd741edc7bd5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TopLevelDomainListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TopLevelDomainListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobHistoryListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobHistoryListResult.Serialization.cs index aa5e5fbb86f3e..78260877680ec 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobHistoryListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobHistoryListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobRun.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobRun.Serialization.cs index 07579350ff560..386787e5401e0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobRun.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredJobRun.Serialization.cs @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebJobId), out propertyOverride); if (Optional.IsDefined(WebJobId) || hasPropertyOverride) { - builder.Append(" web_job_id:"); + builder.Append(" web_job_id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WebJobId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WebJobId}'''"); } else { - builder.AppendLine($" '{WebJobId}'"); + builder.AppendLine($"'{WebJobId}'"); } } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebJobName), out propertyOverride); if (Optional.IsDefined(WebJobName) || hasPropertyOverride) { - builder.Append(" web_job_name:"); + builder.Append(" web_job_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WebJobName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WebJobName}'''"); } else { - builder.AppendLine($" '{WebJobName}'"); + builder.AppendLine($"'{WebJobName}'"); } } } @@ -286,122 +286,122 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" start_time:"); + builder.Append(" start_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" end_time:"); + builder.Append(" end_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Duration), out propertyOverride); if (Optional.IsDefined(Duration) || hasPropertyOverride) { - builder.Append(" duration:"); + builder.Append(" duration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedTimeSpan = TypeFormatters.ToString(Duration.Value, "P"); - builder.AppendLine($" '{formattedTimeSpan}'"); + builder.AppendLine($"'{formattedTimeSpan}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutputUri), out propertyOverride); if (Optional.IsDefined(OutputUri) || hasPropertyOverride) { - builder.Append(" output_url:"); + builder.Append(" output_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{OutputUri.AbsoluteUri}'"); + builder.AppendLine($"'{OutputUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorUri), out propertyOverride); if (Optional.IsDefined(ErrorUri) || hasPropertyOverride) { - builder.Append(" error_url:"); + builder.Append(" error_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ErrorUri.AbsoluteUri}'"); + builder.AppendLine($"'{ErrorUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JobName), out propertyOverride); if (Optional.IsDefined(JobName) || hasPropertyOverride) { - builder.Append(" job_name:"); + builder.Append(" job_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JobName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JobName}'''"); } else { - builder.AppendLine($" '{JobName}'"); + builder.AppendLine($"'{JobName}'"); } } } @@ -409,21 +409,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); if (Optional.IsDefined(Trigger) || hasPropertyOverride) { - builder.Append(" trigger:"); + builder.Append(" trigger: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Trigger.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Trigger}'''"); } else { - builder.AppendLine($" '{Trigger}'"); + builder.AppendLine($"'{Trigger}'"); } } } @@ -432,12 +432,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -458,13 +461,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredWebJobListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredWebJobListResult.Serialization.cs index 6328c931ef063..353c4208c919d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredWebJobListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TriggeredWebJobListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TwitterRegistration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TwitterRegistration.Serialization.cs index 3a03fee240c0c..26133b49c3624 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TwitterRegistration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/TwitterRegistration.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConsumerKey), out propertyOverride); if (Optional.IsDefined(ConsumerKey) || hasPropertyOverride) { - builder.Append(" consumerKey:"); + builder.Append(" consumerKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConsumerKey.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConsumerKey}'''"); } else { - builder.AppendLine($" '{ConsumerKey}'"); + builder.AppendLine($"'{ConsumerKey}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConsumerSecretSettingName), out propertyOverride); if (Optional.IsDefined(ConsumerSecretSettingName) || hasPropertyOverride) { - builder.Append(" consumerSecretSettingName:"); + builder.Append(" consumerSecretSettingName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConsumerSecretSettingName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConsumerSecretSettingName}'''"); } else { - builder.AppendLine($" '{ConsumerSecretSettingName}'"); + builder.AppendLine($"'{ConsumerSecretSettingName}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ValidateResponseError.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ValidateResponseError.Serialization.cs index d4c3284051286..ad4db21df3ef8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ValidateResponseError.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/ValidateResponseError.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); if (Optional.IsDefined(Code) || hasPropertyOverride) { - builder.Append(" code:"); + builder.Append(" code: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Code.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Code}'''"); } else { - builder.AppendLine($" '{Code}'"); + builder.AppendLine($"'{Code}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualApplication.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualApplication.Serialization.cs index 1f5b9b540e0f3..be2c788478750 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualApplication.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualApplication.Serialization.cs @@ -156,21 +156,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualPath), out propertyOverride); if (Optional.IsDefined(VirtualPath) || hasPropertyOverride) { - builder.Append(" virtualPath:"); + builder.Append(" virtualPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualPath}'''"); } else { - builder.AppendLine($" '{VirtualPath}'"); + builder.AppendLine($"'{VirtualPath}'"); } } } @@ -178,21 +178,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhysicalPath), out propertyOverride); if (Optional.IsDefined(PhysicalPath) || hasPropertyOverride) { - builder.Append(" physicalPath:"); + builder.Append(" physicalPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhysicalPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhysicalPath}'''"); } else { - builder.AppendLine($" '{PhysicalPath}'"); + builder.AppendLine($"'{PhysicalPath}'"); } } } @@ -200,15 +200,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreloadEnabled), out propertyOverride); if (Optional.IsDefined(IsPreloadEnabled) || hasPropertyOverride) { - builder.Append(" preloadEnabled:"); + builder.Append(" preloadEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreloadEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -217,17 +217,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualDirectories.Any() || hasPropertyOverride) { - builder.Append(" virtualDirectories:"); + builder.Append(" virtualDirectories: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualDirectories) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " virtualDirectories: "); } builder.AppendLine(" ]"); } @@ -238,12 +238,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -264,13 +267,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualDirectory.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualDirectory.Serialization.cs index c8a3675e71eb5..55e86896d67d3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualDirectory.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualDirectory.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualPath), out propertyOverride); if (Optional.IsDefined(VirtualPath) || hasPropertyOverride) { - builder.Append(" virtualPath:"); + builder.Append(" virtualPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualPath}'''"); } else { - builder.AppendLine($" '{VirtualPath}'"); + builder.AppendLine($"'{VirtualPath}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhysicalPath), out propertyOverride); if (Optional.IsDefined(PhysicalPath) || hasPropertyOverride) { - builder.Append(" physicalPath:"); + builder.Append(" physicalPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhysicalPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhysicalPath}'''"); } else { - builder.AppendLine($" '{PhysicalPath}'"); + builder.AppendLine($"'{PhysicalPath}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualIPMapping.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualIPMapping.Serialization.cs index f47eb4513d60e..23dd4da8ee410 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualIPMapping.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualIPMapping.Serialization.cs @@ -160,21 +160,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualIP), out propertyOverride); if (Optional.IsDefined(VirtualIP) || hasPropertyOverride) { - builder.Append(" virtualIP:"); + builder.Append(" virtualIP: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualIP.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualIP}'''"); } else { - builder.AppendLine($" '{VirtualIP}'"); + builder.AppendLine($"'{VirtualIP}'"); } } } @@ -182,64 +182,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalHttpPort), out propertyOverride); if (Optional.IsDefined(InternalHttpPort) || hasPropertyOverride) { - builder.Append(" internalHttpPort:"); + builder.Append(" internalHttpPort: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {InternalHttpPort.Value}"); + builder.AppendLine($"{InternalHttpPort.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InternalHttpsPort), out propertyOverride); if (Optional.IsDefined(InternalHttpsPort) || hasPropertyOverride) { - builder.Append(" internalHttpsPort:"); + builder.Append(" internalHttpsPort: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {InternalHttpsPort.Value}"); + builder.AppendLine($"{InternalHttpsPort.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInUse), out propertyOverride); if (Optional.IsDefined(IsInUse) || hasPropertyOverride) { - builder.Append(" inUse:"); + builder.Append(" inUse: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsInUse.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceName), out propertyOverride); if (Optional.IsDefined(ServiceName) || hasPropertyOverride) { - builder.Append(" serviceName:"); + builder.Append(" serviceName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ServiceName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ServiceName}'''"); } else { - builder.AppendLine($" '{ServiceName}'"); + builder.AppendLine($"'{ServiceName}'"); } } } @@ -248,12 +248,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -274,13 +277,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationFailureDetails.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationFailureDetails.Serialization.cs index a425f15fcce7e..64d506b4f8c4f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationFailureDetails.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationFailureDetails.Serialization.cs @@ -245,21 +245,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -267,21 +267,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -289,28 +289,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -341,15 +341,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsFailed), out propertyOverride); if (Optional.IsDefined(IsFailed) || hasPropertyOverride) { - builder.Append(" failed:"); + builder.Append(" failed: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsFailed.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -358,17 +358,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (FailedTests.Any() || hasPropertyOverride) { - builder.Append(" failedTests:"); + builder.Append(" failedTests: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in FailedTests) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " failedTests: "); } builder.AppendLine(" ]"); } @@ -380,17 +380,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Warnings.Any() || hasPropertyOverride) { - builder.Append(" warnings:"); + builder.Append(" warnings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Warnings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " warnings: "); } builder.AppendLine(" ]"); } @@ -402,12 +402,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -428,13 +431,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationTestFailure.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationTestFailure.Serialization.cs index ee40daa6ed875..bb10f3271bc8e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationTestFailure.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/VirtualNetworkValidationTestFailure.Serialization.cs @@ -190,21 +190,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -212,21 +212,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -234,28 +234,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TestName), out propertyOverride); if (Optional.IsDefined(TestName) || hasPropertyOverride) { - builder.Append(" testName:"); + builder.Append(" testName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TestName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TestName}'''"); } else { - builder.AppendLine($" '{TestName}'"); + builder.AppendLine($"'{TestName}'"); } } } @@ -286,21 +286,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); if (Optional.IsDefined(Details) || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Details.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Details}'''"); } else { - builder.AppendLine($" '{Details}'"); + builder.AppendLine($"'{Details}'"); } } } @@ -310,12 +310,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -336,13 +339,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupInfo.Serialization.cs index be9f486810d0b..40307a66e7df3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupInfo.Serialization.cs @@ -250,21 +250,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -272,21 +272,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -294,28 +294,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -324,21 +324,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupName), out propertyOverride); if (Optional.IsDefined(BackupName) || hasPropertyOverride) { - builder.Append(" backupName:"); + builder.Append(" backupName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BackupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BackupName}'''"); } else { - builder.AppendLine($" '{BackupName}'"); + builder.AppendLine($"'{BackupName}'"); } } } @@ -346,43 +346,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountUri), out propertyOverride); if (Optional.IsDefined(StorageAccountUri) || hasPropertyOverride) { - builder.Append(" storageAccountUrl:"); + builder.Append(" storageAccountUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountUri.AbsoluteUri}'"); + builder.AppendLine($"'{StorageAccountUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupSchedule), out propertyOverride); if (Optional.IsDefined(BackupSchedule) || hasPropertyOverride) { - builder.Append(" backupSchedule:"); + builder.Append(" backupSchedule: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BackupSchedule, options, 4, false); + AppendChildObject(builder, BackupSchedule, options, 4, false, " backupSchedule: "); } } @@ -391,17 +391,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Databases.Any() || hasPropertyOverride) { - builder.Append(" databases:"); + builder.Append(" databases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Databases) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " databases: "); } builder.AppendLine(" ]"); } @@ -413,12 +413,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -439,13 +442,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupItemListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupItemListResult.Serialization.cs index a778d1be2990e..1b01f4e01668b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupItemListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupItemListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupSchedule.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupSchedule.Serialization.cs index 9c34fb06cd7cb..62cb9000039a8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupSchedule.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppBackupSchedule.Serialization.cs @@ -155,87 +155,87 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrequencyInterval), out propertyOverride); if (Optional.IsDefined(FrequencyInterval) || hasPropertyOverride) { - builder.Append(" frequencyInterval:"); + builder.Append(" frequencyInterval: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FrequencyInterval}"); + builder.AppendLine($"{FrequencyInterval}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FrequencyUnit), out propertyOverride); if (Optional.IsDefined(FrequencyUnit) || hasPropertyOverride) { - builder.Append(" frequencyUnit:"); + builder.Append(" frequencyUnit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FrequencyUnit.ToSerialString()}'"); + builder.AppendLine($"'{FrequencyUnit.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShouldKeepAtLeastOneBackup), out propertyOverride); if (Optional.IsDefined(ShouldKeepAtLeastOneBackup) || hasPropertyOverride) { - builder.Append(" keepAtLeastOneBackup:"); + builder.Append(" keepAtLeastOneBackup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = ShouldKeepAtLeastOneBackup == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionPeriodInDays), out propertyOverride); if (Optional.IsDefined(RetentionPeriodInDays) || hasPropertyOverride) { - builder.Append(" retentionPeriodInDays:"); + builder.Append(" retentionPeriodInDays: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {RetentionPeriodInDays}"); + builder.AppendLine($"{RetentionPeriodInDays}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" startTime:"); + builder.Append(" startTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastExecutedOn), out propertyOverride); if (Optional.IsDefined(LastExecutedOn) || hasPropertyOverride) { - builder.Append(" lastExecutionTime:"); + builder.Append(" lastExecutionTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastExecutedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -243,12 +243,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -269,13 +272,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppCookieExpiration.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppCookieExpiration.Serialization.cs index d7e89984bc5da..f248988d9d39c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppCookieExpiration.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppCookieExpiration.Serialization.cs @@ -119,35 +119,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Convention), out propertyOverride); if (Optional.IsDefined(Convention) || hasPropertyOverride) { - builder.Append(" convention:"); + builder.Append(" convention: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Convention.Value.ToSerialString()}'"); + builder.AppendLine($"'{Convention.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeToExpiration), out propertyOverride); if (Optional.IsDefined(TimeToExpiration) || hasPropertyOverride) { - builder.Append(" timeToExpiration:"); + builder.Append(" timeToExpiration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TimeToExpiration.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TimeToExpiration}'''"); } else { - builder.AppendLine($" '{TimeToExpiration}'"); + builder.AppendLine($"'{TimeToExpiration}'"); } } } @@ -156,12 +156,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -182,13 +185,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppDeploymentListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppDeploymentListResult.Serialization.cs index 424c5106bce0e..3f030a6f4eadc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppDeploymentListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppDeploymentListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppEnabledConfig.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppEnabledConfig.Serialization.cs index e8a9de4f67baa..fa5c74a9c23a5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppEnabledConfig.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppEnabledConfig.Serialization.cs @@ -108,15 +108,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); if (Optional.IsDefined(Enabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -124,12 +124,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -150,13 +153,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppInstanceStatusListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppInstanceStatusListResult.Serialization.cs index 716747941baf4..9cbcbe4ff553a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppInstanceStatusListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppInstanceStatusListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfo.Serialization.cs index a76444fc218b1..10a32ef636122 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfo.Serialization.cs @@ -108,14 +108,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (Optional.IsDefined(Properties) || hasPropertyOverride) { - builder.Append(" properties:"); + builder.Append(" properties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Properties, options, 2, false); + AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -123,12 +123,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -149,13 +152,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfoProperties.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfoProperties.Serialization.cs index 1e3f89acefdb6..d7c50873cd4f9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfoProperties.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppKeyInfoProperties.Serialization.cs @@ -115,21 +115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -137,21 +137,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -160,12 +160,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -186,13 +189,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppListResult.Serialization.cs index 37a0d71dab155..a2ffcff05141f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppLoginInfo.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppLoginInfo.Serialization.cs index c0709aa1a8df3..d5bc83ec42deb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppLoginInfo.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppLoginInfo.Serialization.cs @@ -194,43 +194,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Routes), out propertyOverride); if (Optional.IsDefined(Routes) || hasPropertyOverride) { - builder.Append(" routes:"); + builder.Append(" routes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Routes, options, 2, false); + AppendChildObject(builder, Routes, options, 2, false, " routes: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenStore), out propertyOverride); if (Optional.IsDefined(TokenStore) || hasPropertyOverride) { - builder.Append(" tokenStore:"); + builder.Append(" tokenStore: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TokenStore, options, 2, false); + AppendChildObject(builder, TokenStore, options, 2, false, " tokenStore: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreserveUrlFragmentsForLogins), out propertyOverride); if (Optional.IsDefined(PreserveUrlFragmentsForLogins) || hasPropertyOverride) { - builder.Append(" preserveUrlFragmentsForLogins:"); + builder.Append(" preserveUrlFragmentsForLogins: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = PreserveUrlFragmentsForLogins.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -239,14 +239,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AllowedExternalRedirectUrls.Any() || hasPropertyOverride) { - builder.Append(" allowedExternalRedirectUrls:"); + builder.Append(" allowedExternalRedirectUrls: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AllowedExternalRedirectUrls) { if (item == null) @@ -272,28 +272,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CookieExpiration), out propertyOverride); if (Optional.IsDefined(CookieExpiration) || hasPropertyOverride) { - builder.Append(" cookieExpiration:"); + builder.Append(" cookieExpiration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CookieExpiration, options, 2, false); + AppendChildObject(builder, CookieExpiration, options, 2, false, " cookieExpiration: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Nonce), out propertyOverride); if (Optional.IsDefined(Nonce) || hasPropertyOverride) { - builder.Append(" nonce:"); + builder.Append(" nonce: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Nonce, options, 2, false); + AppendChildObject(builder, Nonce, options, 2, false, " nonce: "); } } @@ -301,12 +301,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -327,13 +330,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeploy.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeploy.Serialization.cs index 992abc347ecf0..6cbab38729733 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeploy.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeploy.Serialization.cs @@ -277,21 +277,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -299,21 +299,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -321,28 +321,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -351,35 +351,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PackageUri), out propertyOverride); if (Optional.IsDefined(PackageUri) || hasPropertyOverride) { - builder.Append(" packageUri:"); + builder.Append(" packageUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PackageUri.AbsoluteUri}'"); + builder.AppendLine($"'{PackageUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionString), out propertyOverride); if (Optional.IsDefined(ConnectionString) || hasPropertyOverride) { - builder.Append(" connectionString:"); + builder.Append(" connectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ConnectionString}'''"); } else { - builder.AppendLine($" '{ConnectionString}'"); + builder.AppendLine($"'{ConnectionString}'"); } } } @@ -387,21 +387,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DBType), out propertyOverride); if (Optional.IsDefined(DBType) || hasPropertyOverride) { - builder.Append(" dbType:"); + builder.Append(" dbType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DBType.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DBType}'''"); } else { - builder.AppendLine($" '{DBType}'"); + builder.AppendLine($"'{DBType}'"); } } } @@ -409,14 +409,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SetParametersXmlFileUri), out propertyOverride); if (Optional.IsDefined(SetParametersXmlFileUri) || hasPropertyOverride) { - builder.Append(" setParametersXmlFileUri:"); + builder.Append(" setParametersXmlFileUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SetParametersXmlFileUri.AbsoluteUri}'"); + builder.AppendLine($"'{SetParametersXmlFileUri.AbsoluteUri}'"); } } @@ -425,17 +425,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (SetParameters.Any() || hasPropertyOverride) { - builder.Append(" setParameters:"); + builder.Append(" setParameters: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in SetParameters) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -443,12 +443,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -459,30 +459,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkipAppData), out propertyOverride); if (Optional.IsDefined(SkipAppData) || hasPropertyOverride) { - builder.Append(" skipAppData:"); + builder.Append(" skipAppData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = SkipAppData.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAppOffline), out propertyOverride); if (Optional.IsDefined(IsAppOffline) || hasPropertyOverride) { - builder.Append(" appOffline:"); + builder.Append(" appOffline: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAppOffline.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -491,12 +491,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -517,13 +520,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLog.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLog.Serialization.cs index 037809ea49e59..d73e592d93d35 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLog.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLog.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -270,17 +270,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Entries.Any() || hasPropertyOverride) { - builder.Append(" entries:"); + builder.Append(" entries: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Entries) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " entries: "); } builder.AppendLine(" ]"); } @@ -292,12 +292,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -318,13 +321,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLogEntry.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLogEntry.Serialization.cs index 434e19ce2045e..77e72e8699792 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLogEntry.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMSDeployLogEntry.Serialization.cs @@ -134,36 +134,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Time), out propertyOverride); if (Optional.IsDefined(Time) || hasPropertyOverride) { - builder.Append(" time:"); + builder.Append(" time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(Time.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -172,12 +172,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -198,13 +201,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMajorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMajorVersion.Serialization.cs index 6837787618f86..ea807d6d99742 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMajorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMajorVersion.Serialization.cs @@ -141,21 +141,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -163,21 +163,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -187,17 +187,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MinorVersions.Any() || hasPropertyOverride) { - builder.Append(" minorVersions:"); + builder.Append(" minorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MinorVersions) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " minorVersions: "); } builder.AppendLine(" ]"); } @@ -208,12 +208,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -234,13 +237,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMinorVersion.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMinorVersion.Serialization.cs index 572af0b0bf051..77ed2afba0106 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMinorVersion.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppMinorVersion.Serialization.cs @@ -130,21 +130,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -152,21 +152,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -174,14 +174,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StackSettings), out propertyOverride); if (Optional.IsDefined(StackSettings) || hasPropertyOverride) { - builder.Append(" stackSettings:"); + builder.Append(" stackSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, StackSettings, options, 2, false); + AppendChildObject(builder, StackSettings, options, 2, false, " stackSettings: "); } } @@ -189,12 +189,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -215,13 +218,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppNetworkTrace.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppNetworkTrace.Serialization.cs index 751b7a8802bf0..032409bfe8b7b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppNetworkTrace.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppNetworkTrace.Serialization.cs @@ -126,21 +126,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); if (Optional.IsDefined(Path) || hasPropertyOverride) { - builder.Append(" path:"); + builder.Append(" path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Path.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Path}'''"); } else { - builder.AppendLine($" '{Path}'"); + builder.AppendLine($"'{Path}'"); } } } @@ -148,21 +148,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Status.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Status}'''"); } else { - builder.AppendLine($" '{Status}'"); + builder.AppendLine($"'{Status}'"); } } } @@ -170,21 +170,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -193,12 +193,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -219,13 +222,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppPushSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppPushSettings.Serialization.cs index af5c08571d999..3e7253037507f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppPushSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppPushSettings.Serialization.cs @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -238,21 +238,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -260,28 +260,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -290,36 +290,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPushEnabled), out propertyOverride); if (Optional.IsDefined(IsPushEnabled) || hasPropertyOverride) { - builder.Append(" isPushEnabled:"); + builder.Append(" isPushEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPushEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TagWhitelistJson), out propertyOverride); if (Optional.IsDefined(TagWhitelistJson) || hasPropertyOverride) { - builder.Append(" tagWhitelistJson:"); + builder.Append(" tagWhitelistJson: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TagWhitelistJson.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TagWhitelistJson}'''"); } else { - builder.AppendLine($" '{TagWhitelistJson}'"); + builder.AppendLine($"'{TagWhitelistJson}'"); } } } @@ -327,21 +327,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TagsRequiringAuth), out propertyOverride); if (Optional.IsDefined(TagsRequiringAuth) || hasPropertyOverride) { - builder.Append(" tagsRequiringAuth:"); + builder.Append(" tagsRequiringAuth: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TagsRequiringAuth.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TagsRequiringAuth}'''"); } else { - builder.AppendLine($" '{TagsRequiringAuth}'"); + builder.AppendLine($"'{TagsRequiringAuth}'"); } } } @@ -349,21 +349,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DynamicTagsJson), out propertyOverride); if (Optional.IsDefined(DynamicTagsJson) || hasPropertyOverride) { - builder.Append(" dynamicTagsJson:"); + builder.Append(" dynamicTagsJson: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DynamicTagsJson.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DynamicTagsJson}'''"); } else { - builder.AppendLine($" '{DynamicTagsJson}'"); + builder.AppendLine($"'{DynamicTagsJson}'"); } } } @@ -373,12 +373,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -399,13 +402,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimeSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimeSettings.Serialization.cs index cd6ed65299d84..13ea8328f7383 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimeSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimeSettings.Serialization.cs @@ -239,21 +239,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) { - builder.Append(" runtimeVersion:"); + builder.Append(" runtimeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RuntimeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RuntimeVersion}'''"); } else { - builder.AppendLine($" '{RuntimeVersion}'"); + builder.AppendLine($"'{RuntimeVersion}'"); } } } @@ -261,133 +261,133 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRemoteDebuggingSupported), out propertyOverride); if (Optional.IsDefined(IsRemoteDebuggingSupported) || hasPropertyOverride) { - builder.Append(" remoteDebuggingSupported:"); + builder.Append(" remoteDebuggingSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRemoteDebuggingSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppInsightsSettings), out propertyOverride); if (Optional.IsDefined(AppInsightsSettings) || hasPropertyOverride) { - builder.Append(" appInsightsSettings:"); + builder.Append(" appInsightsSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AppInsightsSettings, options, 2, false); + AppendChildObject(builder, AppInsightsSettings, options, 2, false, " appInsightsSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubActionSettings), out propertyOverride); if (Optional.IsDefined(GitHubActionSettings) || hasPropertyOverride) { - builder.Append(" gitHubActionSettings:"); + builder.Append(" gitHubActionSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GitHubActionSettings, options, 2, false); + AppendChildObject(builder, GitHubActionSettings, options, 2, false, " gitHubActionSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreview), out propertyOverride); if (Optional.IsDefined(IsPreview) || hasPropertyOverride) { - builder.Append(" isPreview:"); + builder.Append(" isPreview: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreview.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeprecated), out propertyOverride); if (Optional.IsDefined(IsDeprecated) || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeprecated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); if (Optional.IsDefined(IsHidden) || hasPropertyOverride) { - builder.Append(" isHidden:"); + builder.Append(" isHidden: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHidden.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOfLifeOn), out propertyOverride); if (Optional.IsDefined(EndOfLifeOn) || hasPropertyOverride) { - builder.Append(" endOfLifeDate:"); + builder.Append(" endOfLifeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOfLifeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoUpdate), out propertyOverride); if (Optional.IsDefined(IsAutoUpdate) || hasPropertyOverride) { - builder.Append(" isAutoUpdate:"); + builder.Append(" isAutoUpdate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoUpdate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEarlyAccess), out propertyOverride); if (Optional.IsDefined(IsEarlyAccess) || hasPropertyOverride) { - builder.Append(" isEarlyAccess:"); + builder.Append(" isEarlyAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEarlyAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -395,12 +395,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -421,13 +424,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimes.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimes.Serialization.cs index f338a8efe8552..fe25c394718fc 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimes.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppRuntimes.Serialization.cs @@ -153,56 +153,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxRuntimeSettings), out propertyOverride); if (Optional.IsDefined(LinuxRuntimeSettings) || hasPropertyOverride) { - builder.Append(" linuxRuntimeSettings:"); + builder.Append(" linuxRuntimeSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LinuxRuntimeSettings, options, 2, false); + AppendChildObject(builder, LinuxRuntimeSettings, options, 2, false, " linuxRuntimeSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WindowsRuntimeSettings), out propertyOverride); if (Optional.IsDefined(WindowsRuntimeSettings) || hasPropertyOverride) { - builder.Append(" windowsRuntimeSettings:"); + builder.Append(" windowsRuntimeSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, WindowsRuntimeSettings, options, 2, false); + AppendChildObject(builder, WindowsRuntimeSettings, options, 2, false, " windowsRuntimeSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxContainerSettings), out propertyOverride); if (Optional.IsDefined(LinuxContainerSettings) || hasPropertyOverride) { - builder.Append(" linuxContainerSettings:"); + builder.Append(" linuxContainerSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LinuxContainerSettings, options, 2, false); + AppendChildObject(builder, LinuxContainerSettings, options, 2, false, " linuxContainerSettings: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WindowsContainerSettings), out propertyOverride); if (Optional.IsDefined(WindowsContainerSettings) || hasPropertyOverride) { - builder.Append(" windowsContainerSettings:"); + builder.Append(" windowsContainerSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, WindowsContainerSettings, options, 2, false); + AppendChildObject(builder, WindowsContainerSettings, options, 2, false, " windowsContainerSettings: "); } } @@ -210,12 +210,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -236,13 +239,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStack.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStack.Serialization.cs index ad95baf8a121b..a971a5029477e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStack.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStack.Serialization.cs @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -268,35 +268,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.Value.ToString()}'"); + builder.AppendLine($"'{Location.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -304,28 +304,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -334,21 +334,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayText), out propertyOverride); if (Optional.IsDefined(DisplayText) || hasPropertyOverride) { - builder.Append(" displayText:"); + builder.Append(" displayText: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayText.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayText}'''"); } else { - builder.AppendLine($" '{DisplayText}'"); + builder.AppendLine($"'{DisplayText}'"); } } } @@ -356,21 +356,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); if (Optional.IsDefined(Value) || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Value}'''"); } else { - builder.AppendLine($" '{Value}'"); + builder.AppendLine($"'{Value}'"); } } } @@ -380,17 +380,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (MajorVersions.Any() || hasPropertyOverride) { - builder.Append(" majorVersions:"); + builder.Append(" majorVersions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in MajorVersions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " majorVersions: "); } builder.AppendLine(" ]"); } @@ -400,14 +400,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreferredOS), out propertyOverride); if (Optional.IsDefined(PreferredOS) || hasPropertyOverride) { - builder.Append(" preferredOs:"); + builder.Append(" preferredOs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PreferredOS.Value.ToSerialString()}'"); + builder.AppendLine($"'{PreferredOS.Value.ToSerialString()}'"); } } @@ -416,12 +416,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -442,13 +445,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStackListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStackListResult.Serialization.cs index deb1407f1e711..f1e6ac54e0d6a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStackListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebAppStackListResult.Serialization.cs @@ -125,17 +125,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -145,21 +145,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -168,12 +168,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -194,13 +197,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebJobCListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebJobCListResult.Serialization.cs index d0cd31b394cfd..9b4df51b1f24d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebJobCListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebJobCListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebSiteAnalysisDefinitionListResult.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebSiteAnalysisDefinitionListResult.Serialization.cs index 2d7729d799691..1719241534443 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebSiteAnalysisDefinitionListResult.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WebSiteAnalysisDefinitionListResult.Serialization.cs @@ -126,17 +126,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Value.Any() || hasPropertyOverride) { - builder.Append(" value:"); + builder.Append(" value: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true); + AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -146,21 +146,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); if (Optional.IsDefined(NextLink) || hasPropertyOverride) { - builder.Append(" nextLink:"); + builder.Append(" nextLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NextLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NextLink}'''"); } else { - builder.AppendLine($" '{NextLink}'"); + builder.AppendLine($"'{NextLink}'"); } } } @@ -169,12 +169,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -195,13 +198,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WindowsJavaContainerSettings.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WindowsJavaContainerSettings.Serialization.cs index 7bfb88a44eeea..699cf255b492b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WindowsJavaContainerSettings.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/Models/WindowsJavaContainerSettings.Serialization.cs @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainer), out propertyOverride); if (Optional.IsDefined(JavaContainer) || hasPropertyOverride) { - builder.Append(" javaContainer:"); + builder.Append(" javaContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainer}'''"); } else { - builder.AppendLine($" '{JavaContainer}'"); + builder.AppendLine($"'{JavaContainer}'"); } } } @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainerVersion), out propertyOverride); if (Optional.IsDefined(JavaContainerVersion) || hasPropertyOverride) { - builder.Append(" javaContainerVersion:"); + builder.Append(" javaContainerVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainerVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainerVersion}'''"); } else { - builder.AppendLine($" '{JavaContainerVersion}'"); + builder.AppendLine($"'{JavaContainerVersion}'"); } } } @@ -249,90 +249,90 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPreview), out propertyOverride); if (Optional.IsDefined(IsPreview) || hasPropertyOverride) { - builder.Append(" isPreview:"); + builder.Append(" isPreview: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsPreview.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeprecated), out propertyOverride); if (Optional.IsDefined(IsDeprecated) || hasPropertyOverride) { - builder.Append(" isDeprecated:"); + builder.Append(" isDeprecated: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeprecated.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); if (Optional.IsDefined(IsHidden) || hasPropertyOverride) { - builder.Append(" isHidden:"); + builder.Append(" isHidden: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHidden.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOfLifeOn), out propertyOverride); if (Optional.IsDefined(EndOfLifeOn) || hasPropertyOverride) { - builder.Append(" endOfLifeDate:"); + builder.Append(" endOfLifeDate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOfLifeOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoUpdate), out propertyOverride); if (Optional.IsDefined(IsAutoUpdate) || hasPropertyOverride) { - builder.Append(" isAutoUpdate:"); + builder.Append(" isAutoUpdate: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoUpdate.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEarlyAccess), out propertyOverride); if (Optional.IsDefined(IsEarlyAccess) || hasPropertyOverride) { - builder.Append(" isEarlyAccess:"); + builder.Append(" isEarlyAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEarlyAccess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -340,12 +340,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -366,13 +369,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/NetworkFeatureData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/NetworkFeatureData.Serialization.cs index ad6e7b4ee554b..2f1c8a78a12ad 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/NetworkFeatureData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/NetworkFeatureData.Serialization.cs @@ -246,21 +246,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -290,28 +290,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -320,21 +320,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkName), out propertyOverride); if (Optional.IsDefined(VirtualNetworkName) || hasPropertyOverride) { - builder.Append(" virtualNetworkName:"); + builder.Append(" virtualNetworkName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VirtualNetworkName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VirtualNetworkName}'''"); } else { - builder.AppendLine($" '{VirtualNetworkName}'"); + builder.AppendLine($"'{VirtualNetworkName}'"); } } } @@ -342,14 +342,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkConnection), out propertyOverride); if (Optional.IsDefined(VirtualNetworkConnection) || hasPropertyOverride) { - builder.Append(" virtualNetworkConnection:"); + builder.Append(" virtualNetworkConnection: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, VirtualNetworkConnection, options, 4, false); + AppendChildObject(builder, VirtualNetworkConnection, options, 4, false, " virtualNetworkConnection: "); } } @@ -358,17 +358,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HybridConnections.Any() || hasPropertyOverride) { - builder.Append(" hybridConnections:"); + builder.Append(" hybridConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HybridConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " hybridConnections: "); } builder.AppendLine(" ]"); } @@ -380,17 +380,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HybridConnectionsV2.Any() || hasPropertyOverride) { - builder.Append(" hybridConnectionsV2:"); + builder.Append(" hybridConnectionsV2: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HybridConnectionsV2) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " hybridConnectionsV2: "); } builder.AppendLine(" ]"); } @@ -402,12 +402,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -428,13 +431,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PremierAddOnData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PremierAddOnData.Serialization.cs index 2a4251e32a761..a5a80658f8f25 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PremierAddOnData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PremierAddOnData.Serialization.cs @@ -258,21 +258,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -280,14 +280,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -296,17 +296,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -314,12 +314,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -330,21 +330,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -352,28 +352,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -382,21 +382,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Sku.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Sku}'''"); } else { - builder.AppendLine($" '{Sku}'"); + builder.AppendLine($"'{Sku}'"); } } } @@ -404,21 +404,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -426,21 +426,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Vendor), out propertyOverride); if (Optional.IsDefined(Vendor) || hasPropertyOverride) { - builder.Append(" vendor:"); + builder.Append(" vendor: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Vendor.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Vendor}'''"); } else { - builder.AppendLine($" '{Vendor}'"); + builder.AppendLine($"'{Vendor}'"); } } } @@ -448,21 +448,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplacePublisher), out propertyOverride); if (Optional.IsDefined(MarketplacePublisher) || hasPropertyOverride) { - builder.Append(" marketplacePublisher:"); + builder.Append(" marketplacePublisher: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplacePublisher.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplacePublisher}'''"); } else { - builder.AppendLine($" '{MarketplacePublisher}'"); + builder.AppendLine($"'{MarketplacePublisher}'"); } } } @@ -470,21 +470,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MarketplaceOffer), out propertyOverride); if (Optional.IsDefined(MarketplaceOffer) || hasPropertyOverride) { - builder.Append(" marketplaceOffer:"); + builder.Append(" marketplaceOffer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (MarketplaceOffer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{MarketplaceOffer}'''"); } else { - builder.AppendLine($" '{MarketplaceOffer}'"); + builder.AppendLine($"'{MarketplaceOffer}'"); } } } @@ -494,12 +494,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -520,13 +523,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PrivateAccessData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PrivateAccessData.Serialization.cs index eb96bf4b852c4..8efd8430f8791 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PrivateAccessData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PrivateAccessData.Serialization.cs @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -254,28 +254,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -284,15 +284,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -301,17 +301,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualNetworks.Any() || hasPropertyOverride) { - builder.Append(" virtualNetworks:"); + builder.Append(" virtualNetworks: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualNetworks) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " virtualNetworks: "); } builder.AppendLine(" ]"); } @@ -323,12 +323,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -349,13 +352,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessInfoData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessInfoData.Serialization.cs index f32e21090f28c..fab5c803816f3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessInfoData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessInfoData.Serialization.cs @@ -717,21 +717,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -739,21 +739,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -761,28 +761,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -791,35 +791,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identifier), out propertyOverride); if (Optional.IsDefined(Identifier) || hasPropertyOverride) { - builder.Append(" identifier:"); + builder.Append(" identifier: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Identifier.Value}"); + builder.AppendLine($"{Identifier.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentName), out propertyOverride); if (Optional.IsDefined(DeploymentName) || hasPropertyOverride) { - builder.Append(" deployment_name:"); + builder.Append(" deployment_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DeploymentName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DeploymentName}'''"); } else { - builder.AppendLine($" '{DeploymentName}'"); + builder.AppendLine($"'{DeploymentName}'"); } } } @@ -827,21 +827,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Href), out propertyOverride); if (Optional.IsDefined(Href) || hasPropertyOverride) { - builder.Append(" href:"); + builder.Append(" href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Href.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Href}'''"); } else { - builder.AppendLine($" '{Href}'"); + builder.AppendLine($"'{Href}'"); } } } @@ -849,21 +849,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Minidump), out propertyOverride); if (Optional.IsDefined(Minidump) || hasPropertyOverride) { - builder.Append(" minidump:"); + builder.Append(" minidump: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Minidump.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Minidump}'''"); } else { - builder.AppendLine($" '{Minidump}'"); + builder.AppendLine($"'{Minidump}'"); } } } @@ -871,65 +871,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsProfileRunning), out propertyOverride); if (Optional.IsDefined(IsProfileRunning) || hasPropertyOverride) { - builder.Append(" is_profile_running:"); + builder.Append(" is_profile_running: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsProfileRunning.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsIisProfileRunning), out propertyOverride); if (Optional.IsDefined(IsIisProfileRunning) || hasPropertyOverride) { - builder.Append(" is_iis_profile_running:"); + builder.Append(" is_iis_profile_running: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsIisProfileRunning.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IisProfileTimeoutInSeconds), out propertyOverride); if (Optional.IsDefined(IisProfileTimeoutInSeconds) || hasPropertyOverride) { - builder.Append(" iis_profile_timeout_in_seconds:"); + builder.Append(" iis_profile_timeout_in_seconds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IisProfileTimeoutInSeconds.Value.ToString()}'"); + builder.AppendLine($"'{IisProfileTimeoutInSeconds.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parent), out propertyOverride); if (Optional.IsDefined(Parent) || hasPropertyOverride) { - builder.Append(" parent:"); + builder.Append(" parent: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Parent.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Parent}'''"); } else { - builder.AppendLine($" '{Parent}'"); + builder.AppendLine($"'{Parent}'"); } } } @@ -939,14 +939,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Children.Any() || hasPropertyOverride) { - builder.Append(" children:"); + builder.Append(" children: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Children) { if (item == null) @@ -974,17 +974,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Threads.Any() || hasPropertyOverride) { - builder.Append(" threads:"); + builder.Append(" threads: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Threads) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " threads: "); } builder.AppendLine(" ]"); } @@ -996,14 +996,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (OpenFileHandles.Any() || hasPropertyOverride) { - builder.Append(" open_file_handles:"); + builder.Append(" open_file_handles: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in OpenFileHandles) { if (item == null) @@ -1031,17 +1031,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Modules.Any() || hasPropertyOverride) { - builder.Append(" modules:"); + builder.Append(" modules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Modules) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " modules: "); } builder.AppendLine(" ]"); } @@ -1051,21 +1051,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileName), out propertyOverride); if (Optional.IsDefined(FileName) || hasPropertyOverride) { - builder.Append(" file_name:"); + builder.Append(" file_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FileName}'''"); } else { - builder.AppendLine($" '{FileName}'"); + builder.AppendLine($"'{FileName}'"); } } } @@ -1073,21 +1073,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CommandLine), out propertyOverride); if (Optional.IsDefined(CommandLine) || hasPropertyOverride) { - builder.Append(" command_line:"); + builder.Append(" command_line: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CommandLine.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CommandLine}'''"); } else { - builder.AppendLine($" '{CommandLine}'"); + builder.AppendLine($"'{CommandLine}'"); } } } @@ -1095,21 +1095,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserName), out propertyOverride); if (Optional.IsDefined(UserName) || hasPropertyOverride) { - builder.Append(" user_name:"); + builder.Append(" user_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserName}'''"); } else { - builder.AppendLine($" '{UserName}'"); + builder.AppendLine($"'{UserName}'"); } } } @@ -1117,78 +1117,78 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HandleCount), out propertyOverride); if (Optional.IsDefined(HandleCount) || hasPropertyOverride) { - builder.Append(" handle_count:"); + builder.Append(" handle_count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {HandleCount.Value}"); + builder.AppendLine($"{HandleCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModuleCount), out propertyOverride); if (Optional.IsDefined(ModuleCount) || hasPropertyOverride) { - builder.Append(" module_count:"); + builder.Append(" module_count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ModuleCount.Value}"); + builder.AppendLine($"{ModuleCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThreadCount), out propertyOverride); if (Optional.IsDefined(ThreadCount) || hasPropertyOverride) { - builder.Append(" thread_count:"); + builder.Append(" thread_count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ThreadCount.Value}"); + builder.AppendLine($"{ThreadCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" start_time:"); + builder.Append(" start_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalCpuTime), out propertyOverride); if (Optional.IsDefined(TotalCpuTime) || hasPropertyOverride) { - builder.Append(" total_cpu_time:"); + builder.Append(" total_cpu_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TotalCpuTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TotalCpuTime}'''"); } else { - builder.AppendLine($" '{TotalCpuTime}'"); + builder.AppendLine($"'{TotalCpuTime}'"); } } } @@ -1196,21 +1196,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserCpuTime), out propertyOverride); if (Optional.IsDefined(UserCpuTime) || hasPropertyOverride) { - builder.Append(" user_cpu_time:"); + builder.Append(" user_cpu_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (UserCpuTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{UserCpuTime}'''"); } else { - builder.AppendLine($" '{UserCpuTime}'"); + builder.AppendLine($"'{UserCpuTime}'"); } } } @@ -1218,21 +1218,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivilegedCpuTime), out propertyOverride); if (Optional.IsDefined(PrivilegedCpuTime) || hasPropertyOverride) { - builder.Append(" privileged_cpu_time:"); + builder.Append(" privileged_cpu_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PrivilegedCpuTime.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PrivilegedCpuTime}'''"); } else { - builder.AppendLine($" '{PrivilegedCpuTime}'"); + builder.AppendLine($"'{PrivilegedCpuTime}'"); } } } @@ -1240,141 +1240,141 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkingSet), out propertyOverride); if (Optional.IsDefined(WorkingSet) || hasPropertyOverride) { - builder.Append(" working_set:"); + builder.Append(" working_set: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WorkingSet.Value.ToString()}'"); + builder.AppendLine($"'{WorkingSet.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PeakWorkingSet), out propertyOverride); if (Optional.IsDefined(PeakWorkingSet) || hasPropertyOverride) { - builder.Append(" peak_working_set:"); + builder.Append(" peak_working_set: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PeakWorkingSet.Value.ToString()}'"); + builder.AppendLine($"'{PeakWorkingSet.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateMemory), out propertyOverride); if (Optional.IsDefined(PrivateMemory) || hasPropertyOverride) { - builder.Append(" private_memory:"); + builder.Append(" private_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PrivateMemory.Value.ToString()}'"); + builder.AppendLine($"'{PrivateMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualMemory), out propertyOverride); if (Optional.IsDefined(VirtualMemory) || hasPropertyOverride) { - builder.Append(" virtual_memory:"); + builder.Append(" virtual_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VirtualMemory.Value.ToString()}'"); + builder.AppendLine($"'{VirtualMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PeakVirtualMemory), out propertyOverride); if (Optional.IsDefined(PeakVirtualMemory) || hasPropertyOverride) { - builder.Append(" peak_virtual_memory:"); + builder.Append(" peak_virtual_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PeakVirtualMemory.Value.ToString()}'"); + builder.AppendLine($"'{PeakVirtualMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PagedSystemMemory), out propertyOverride); if (Optional.IsDefined(PagedSystemMemory) || hasPropertyOverride) { - builder.Append(" paged_system_memory:"); + builder.Append(" paged_system_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PagedSystemMemory.Value.ToString()}'"); + builder.AppendLine($"'{PagedSystemMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NonPagedSystemMemory), out propertyOverride); if (Optional.IsDefined(NonPagedSystemMemory) || hasPropertyOverride) { - builder.Append(" non_paged_system_memory:"); + builder.Append(" non_paged_system_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{NonPagedSystemMemory.Value.ToString()}'"); + builder.AppendLine($"'{NonPagedSystemMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PagedMemory), out propertyOverride); if (Optional.IsDefined(PagedMemory) || hasPropertyOverride) { - builder.Append(" paged_memory:"); + builder.Append(" paged_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PagedMemory.Value.ToString()}'"); + builder.AppendLine($"'{PagedMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PeakPagedMemory), out propertyOverride); if (Optional.IsDefined(PeakPagedMemory) || hasPropertyOverride) { - builder.Append(" peak_paged_memory:"); + builder.Append(" peak_paged_memory: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PeakPagedMemory.Value.ToString()}'"); + builder.AppendLine($"'{PeakPagedMemory.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeStamp), out propertyOverride); if (Optional.IsDefined(TimeStamp) || hasPropertyOverride) { - builder.Append(" time_stamp:"); + builder.Append(" time_stamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(TimeStamp.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -1383,17 +1383,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EnvironmentVariables.Any() || hasPropertyOverride) { - builder.Append(" environment_variables:"); + builder.Append(" environment_variables: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in EnvironmentVariables) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -1401,12 +1401,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -1417,51 +1417,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsScmSite), out propertyOverride); if (Optional.IsDefined(IsScmSite) || hasPropertyOverride) { - builder.Append(" is_scm_site:"); + builder.Append(" is_scm_site: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsScmSite.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsWebjob), out propertyOverride); if (Optional.IsDefined(IsWebjob) || hasPropertyOverride) { - builder.Append(" is_webjob:"); + builder.Append(" is_webjob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsWebjob.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -1471,12 +1471,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1497,13 +1500,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessModuleInfoData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessModuleInfoData.Serialization.cs index e00f2724ce91c..621200ec083e6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessModuleInfoData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ProcessModuleInfoData.Serialization.cs @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -341,28 +341,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -371,21 +371,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseAddress), out propertyOverride); if (Optional.IsDefined(BaseAddress) || hasPropertyOverride) { - builder.Append(" base_address:"); + builder.Append(" base_address: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BaseAddress.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BaseAddress}'''"); } else { - builder.AppendLine($" '{BaseAddress}'"); + builder.AppendLine($"'{BaseAddress}'"); } } } @@ -393,21 +393,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileName), out propertyOverride); if (Optional.IsDefined(FileName) || hasPropertyOverride) { - builder.Append(" file_name:"); + builder.Append(" file_name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FileName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FileName}'''"); } else { - builder.AppendLine($" '{FileName}'"); + builder.AppendLine($"'{FileName}'"); } } } @@ -415,21 +415,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Href), out propertyOverride); if (Optional.IsDefined(Href) || hasPropertyOverride) { - builder.Append(" href:"); + builder.Append(" href: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Href.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Href}'''"); } else { - builder.AppendLine($" '{Href}'"); + builder.AppendLine($"'{Href}'"); } } } @@ -437,21 +437,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FilePath), out propertyOverride); if (Optional.IsDefined(FilePath) || hasPropertyOverride) { - builder.Append(" file_path:"); + builder.Append(" file_path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FilePath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FilePath}'''"); } else { - builder.AppendLine($" '{FilePath}'"); + builder.AppendLine($"'{FilePath}'"); } } } @@ -459,35 +459,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModuleMemorySize), out propertyOverride); if (Optional.IsDefined(ModuleMemorySize) || hasPropertyOverride) { - builder.Append(" module_memory_size:"); + builder.Append(" module_memory_size: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ModuleMemorySize.Value}"); + builder.AppendLine($"{ModuleMemorySize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileVersion), out propertyOverride); if (Optional.IsDefined(FileVersion) || hasPropertyOverride) { - builder.Append(" file_version:"); + builder.Append(" file_version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FileVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FileVersion}'''"); } else { - builder.AppendLine($" '{FileVersion}'"); + builder.AppendLine($"'{FileVersion}'"); } } } @@ -495,21 +495,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FileDescription), out propertyOverride); if (Optional.IsDefined(FileDescription) || hasPropertyOverride) { - builder.Append(" file_description:"); + builder.Append(" file_description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FileDescription.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FileDescription}'''"); } else { - builder.AppendLine($" '{FileDescription}'"); + builder.AppendLine($"'{FileDescription}'"); } } } @@ -517,21 +517,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Product), out propertyOverride); if (Optional.IsDefined(Product) || hasPropertyOverride) { - builder.Append(" product:"); + builder.Append(" product: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Product.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Product}'''"); } else { - builder.AppendLine($" '{Product}'"); + builder.AppendLine($"'{Product}'"); } } } @@ -539,21 +539,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProductVersion), out propertyOverride); if (Optional.IsDefined(ProductVersion) || hasPropertyOverride) { - builder.Append(" product_version:"); + builder.Append(" product_version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProductVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProductVersion}'''"); } else { - builder.AppendLine($" '{ProductVersion}'"); + builder.AppendLine($"'{ProductVersion}'"); } } } @@ -561,36 +561,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDebug), out propertyOverride); if (Optional.IsDefined(IsDebug) || hasPropertyOverride) { - builder.Append(" is_debug:"); + builder.Append(" is_debug: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDebug.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Language), out propertyOverride); if (Optional.IsDefined(Language) || hasPropertyOverride) { - builder.Append(" language:"); + builder.Append(" language: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Language.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Language}'''"); } else { - builder.AppendLine($" '{Language}'"); + builder.AppendLine($"'{Language}'"); } } } @@ -600,12 +600,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -626,13 +629,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublicCertificateData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublicCertificateData.Serialization.cs index c674ab09625a5..46a00dd4749ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublicCertificateData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublicCertificateData.Serialization.cs @@ -210,21 +210,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -254,28 +254,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -284,49 +284,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Blob), out propertyOverride); if (Optional.IsDefined(Blob) || hasPropertyOverride) { - builder.Append(" blob:"); + builder.Append(" blob: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Blob.ToString()}'"); + builder.AppendLine($"'{Blob.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicCertificateLocation), out propertyOverride); if (Optional.IsDefined(PublicCertificateLocation) || hasPropertyOverride) { - builder.Append(" publicCertificateLocation:"); + builder.Append(" publicCertificateLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{PublicCertificateLocation.Value.ToSerialString()}'"); + builder.AppendLine($"'{PublicCertificateLocation.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ThumbprintString), out propertyOverride); if (Optional.IsDefined(ThumbprintString) || hasPropertyOverride) { - builder.Append(" thumbprint:"); + builder.Append(" thumbprint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ThumbprintString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ThumbprintString}'''"); } else { - builder.AppendLine($" '{ThumbprintString}'"); + builder.AppendLine($"'{ThumbprintString}'"); } } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublishingUserData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublishingUserData.Serialization.cs index 952814570af5a..7cbedd08276d9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublishingUserData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/PublishingUserData.Serialization.cs @@ -227,21 +227,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -249,21 +249,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -271,28 +271,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -301,21 +301,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingUserName), out propertyOverride); if (Optional.IsDefined(PublishingUserName) || hasPropertyOverride) { - builder.Append(" publishingUserName:"); + builder.Append(" publishingUserName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingUserName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingUserName}'''"); } else { - builder.AppendLine($" '{PublishingUserName}'"); + builder.AppendLine($"'{PublishingUserName}'"); } } } @@ -323,21 +323,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingPassword), out propertyOverride); if (Optional.IsDefined(PublishingPassword) || hasPropertyOverride) { - builder.Append(" publishingPassword:"); + builder.Append(" publishingPassword: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingPassword.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingPassword}'''"); } else { - builder.AppendLine($" '{PublishingPassword}'"); + builder.AppendLine($"'{PublishingPassword}'"); } } } @@ -345,21 +345,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingPasswordHash), out propertyOverride); if (Optional.IsDefined(PublishingPasswordHash) || hasPropertyOverride) { - builder.Append(" publishingPasswordHash:"); + builder.Append(" publishingPasswordHash: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingPasswordHash.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingPasswordHash}'''"); } else { - builder.AppendLine($" '{PublishingPasswordHash}'"); + builder.AppendLine($"'{PublishingPasswordHash}'"); } } } @@ -367,21 +367,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingPasswordHashSalt), out propertyOverride); if (Optional.IsDefined(PublishingPasswordHashSalt) || hasPropertyOverride) { - builder.Append(" publishingPasswordHashSalt:"); + builder.Append(" publishingPasswordHashSalt: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingPasswordHashSalt.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingPasswordHashSalt}'''"); } else { - builder.AppendLine($" '{PublishingPasswordHashSalt}'"); + builder.AppendLine($"'{PublishingPasswordHashSalt}'"); } } } @@ -389,14 +389,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScmUri), out propertyOverride); if (Optional.IsDefined(ScmUri) || hasPropertyOverride) { - builder.Append(" scmUri:"); + builder.Append(" scmUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ScmUri.AbsoluteUri}'"); + builder.AppendLine($"'{ScmUri.AbsoluteUri}'"); } } @@ -405,12 +405,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -431,13 +434,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RecommendationRuleData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RecommendationRuleData.Serialization.cs index 8099163ddd836..4e115a061715b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RecommendationRuleData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RecommendationRuleData.Serialization.cs @@ -343,21 +343,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -365,21 +365,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -387,28 +387,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -417,21 +417,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationName), out propertyOverride); if (Optional.IsDefined(RecommendationName) || hasPropertyOverride) { - builder.Append(" recommendationName:"); + builder.Append(" recommendationName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RecommendationName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RecommendationName}'''"); } else { - builder.AppendLine($" '{RecommendationName}'"); + builder.AppendLine($"'{RecommendationName}'"); } } } @@ -439,21 +439,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); if (Optional.IsDefined(DisplayName) || hasPropertyOverride) { - builder.Append(" displayName:"); + builder.Append(" displayName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DisplayName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DisplayName}'''"); } else { - builder.AppendLine($" '{DisplayName}'"); + builder.AppendLine($"'{DisplayName}'"); } } } @@ -461,21 +461,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -483,35 +483,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationId), out propertyOverride); if (Optional.IsDefined(RecommendationId) || hasPropertyOverride) { - builder.Append(" recommendationId:"); + builder.Append(" recommendationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RecommendationId.Value.ToString()}'"); + builder.AppendLine($"'{RecommendationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -519,21 +519,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionName), out propertyOverride); if (Optional.IsDefined(ActionName) || hasPropertyOverride) { - builder.Append(" actionName:"); + builder.Append(" actionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ActionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ActionName}'''"); } else { - builder.AppendLine($" '{ActionName}'"); + builder.AppendLine($"'{ActionName}'"); } } } @@ -541,28 +541,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Level), out propertyOverride); if (Optional.IsDefined(Level) || hasPropertyOverride) { - builder.Append(" level:"); + builder.Append(" level: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Level.Value.ToSerialString()}'"); + builder.AppendLine($"'{Level.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Channels), out propertyOverride); if (Optional.IsDefined(Channels) || hasPropertyOverride) { - builder.Append(" channels:"); + builder.Append(" channels: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Channels.Value.ToSerialString()}'"); + builder.AppendLine($"'{Channels.Value.ToSerialString()}'"); } } @@ -571,14 +571,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CategoryTags.Any() || hasPropertyOverride) { - builder.Append(" categoryTags:"); + builder.Append(" categoryTags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CategoryTags) { if (item == null) @@ -604,36 +604,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDynamic), out propertyOverride); if (Optional.IsDefined(IsDynamic) || hasPropertyOverride) { - builder.Append(" isDynamic:"); + builder.Append(" isDynamic: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDynamic.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtensionName), out propertyOverride); if (Optional.IsDefined(ExtensionName) || hasPropertyOverride) { - builder.Append(" extensionName:"); + builder.Append(" extensionName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ExtensionName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ExtensionName}'''"); } else { - builder.AppendLine($" '{ExtensionName}'"); + builder.AppendLine($"'{ExtensionName}'"); } } } @@ -641,21 +641,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BladeName), out propertyOverride); if (Optional.IsDefined(BladeName) || hasPropertyOverride) { - builder.Append(" bladeName:"); + builder.Append(" bladeName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BladeName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BladeName}'''"); } else { - builder.AppendLine($" '{BladeName}'"); + builder.AppendLine($"'{BladeName}'"); } } } @@ -663,21 +663,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForwardLink), out propertyOverride); if (Optional.IsDefined(ForwardLink) || hasPropertyOverride) { - builder.Append(" forwardLink:"); + builder.Append(" forwardLink: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ForwardLink.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ForwardLink}'''"); } else { - builder.AppendLine($" '{ForwardLink}'"); + builder.AppendLine($"'{ForwardLink}'"); } } } @@ -687,12 +687,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -713,13 +716,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RelayServiceConnectionEntityData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RelayServiceConnectionEntityData.Serialization.cs index 71c124f41bb39..c633b1393319e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RelayServiceConnectionEntityData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RelayServiceConnectionEntityData.Serialization.cs @@ -242,21 +242,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -264,21 +264,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -286,28 +286,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -316,21 +316,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EntityName), out propertyOverride); if (Optional.IsDefined(EntityName) || hasPropertyOverride) { - builder.Append(" entityName:"); + builder.Append(" entityName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EntityName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EntityName}'''"); } else { - builder.AppendLine($" '{EntityName}'"); + builder.AppendLine($"'{EntityName}'"); } } } @@ -338,21 +338,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EntityConnectionString), out propertyOverride); if (Optional.IsDefined(EntityConnectionString) || hasPropertyOverride) { - builder.Append(" entityConnectionString:"); + builder.Append(" entityConnectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (EntityConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{EntityConnectionString}'''"); } else { - builder.AppendLine($" '{EntityConnectionString}'"); + builder.AppendLine($"'{EntityConnectionString}'"); } } } @@ -360,21 +360,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceConnectionString), out propertyOverride); if (Optional.IsDefined(ResourceConnectionString) || hasPropertyOverride) { - builder.Append(" resourceConnectionString:"); + builder.Append(" resourceConnectionString: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceConnectionString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceConnectionString}'''"); } else { - builder.AppendLine($" '{ResourceConnectionString}'"); + builder.AppendLine($"'{ResourceConnectionString}'"); } } } @@ -382,21 +382,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Hostname), out propertyOverride); if (Optional.IsDefined(Hostname) || hasPropertyOverride) { - builder.Append(" hostname:"); + builder.Append(" hostname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Hostname.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Hostname}'''"); } else { - builder.AppendLine($" '{Hostname}'"); + builder.AppendLine($"'{Hostname}'"); } } } @@ -404,28 +404,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); if (Optional.IsDefined(Port) || hasPropertyOverride) { - builder.Append(" port:"); + builder.Append(" port: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Port.Value}"); + builder.AppendLine($"{Port.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BiztalkUri), out propertyOverride); if (Optional.IsDefined(BiztalkUri) || hasPropertyOverride) { - builder.Append(" biztalkUri:"); + builder.Append(" biztalkUri: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{BiztalkUri.AbsoluteUri}'"); + builder.AppendLine($"'{BiztalkUri.AbsoluteUri}'"); } } @@ -434,12 +434,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -460,13 +463,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RemotePrivateEndpointConnectionARMResourceData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RemotePrivateEndpointConnectionARMResourceData.Serialization.cs index 467838070be41..27b21a54e03d7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RemotePrivateEndpointConnectionARMResourceData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/RemotePrivateEndpointConnectionARMResourceData.Serialization.cs @@ -250,21 +250,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -272,21 +272,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -294,28 +294,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -324,21 +324,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -346,28 +346,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) { - builder.Append(" privateEndpoint:"); + builder.Append(" privateEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateEndpoint, options, 4, false); + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) { - builder.Append(" privateLinkServiceConnectionState:"); + builder.Append(" privateLinkServiceConnectionState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false); + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); } } @@ -376,14 +376,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPAddresses.Any() || hasPropertyOverride) { - builder.Append(" ipAddresses:"); + builder.Append(" ipAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPAddresses) { if (item == null) @@ -403,12 +403,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -429,13 +432,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ResourceHealthMetadataData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ResourceHealthMetadataData.Serialization.cs index 3d0284c336f4c..66e157ea8f1ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ResourceHealthMetadataData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/ResourceHealthMetadataData.Serialization.cs @@ -194,21 +194,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -216,21 +216,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -238,28 +238,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -268,21 +268,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); if (Optional.IsDefined(Category) || hasPropertyOverride) { - builder.Append(" category:"); + builder.Append(" category: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Category.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Category}'''"); } else { - builder.AppendLine($" '{Category}'"); + builder.AppendLine($"'{Category}'"); } } } @@ -290,15 +290,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSignalAvailable), out propertyOverride); if (Optional.IsDefined(IsSignalAvailable) || hasPropertyOverride) { - builder.Append(" signalAvailability:"); + builder.Append(" signalAvailability: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSignalAvailable.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -307,12 +307,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -333,13 +336,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteConfigData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteConfigData.Serialization.cs index e16bb400242fb..f92dd3033d8c0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteConfigData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteConfigData.Serialization.cs @@ -1792,21 +1792,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -1814,21 +1814,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -1836,28 +1836,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -1866,14 +1866,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfWorkers), out propertyOverride); if (Optional.IsDefined(NumberOfWorkers) || hasPropertyOverride) { - builder.Append(" numberOfWorkers:"); + builder.Append(" numberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {NumberOfWorkers.Value}"); + builder.AppendLine($"{NumberOfWorkers.Value}"); } } @@ -1882,14 +1882,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (DefaultDocuments.Any() || hasPropertyOverride) { - builder.Append(" defaultDocuments:"); + builder.Append(" defaultDocuments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in DefaultDocuments) { if (item == null) @@ -1915,21 +1915,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetFrameworkVersion), out propertyOverride); if (Optional.IsDefined(NetFrameworkVersion) || hasPropertyOverride) { - builder.Append(" netFrameworkVersion:"); + builder.Append(" netFrameworkVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NetFrameworkVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NetFrameworkVersion}'''"); } else { - builder.AppendLine($" '{NetFrameworkVersion}'"); + builder.AppendLine($"'{NetFrameworkVersion}'"); } } } @@ -1937,21 +1937,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PhpVersion), out propertyOverride); if (Optional.IsDefined(PhpVersion) || hasPropertyOverride) { - builder.Append(" phpVersion:"); + builder.Append(" phpVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PhpVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PhpVersion}'''"); } else { - builder.AppendLine($" '{PhpVersion}'"); + builder.AppendLine($"'{PhpVersion}'"); } } } @@ -1959,21 +1959,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PythonVersion), out propertyOverride); if (Optional.IsDefined(PythonVersion) || hasPropertyOverride) { - builder.Append(" pythonVersion:"); + builder.Append(" pythonVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PythonVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PythonVersion}'''"); } else { - builder.AppendLine($" '{PythonVersion}'"); + builder.AppendLine($"'{PythonVersion}'"); } } } @@ -1981,21 +1981,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NodeVersion), out propertyOverride); if (Optional.IsDefined(NodeVersion) || hasPropertyOverride) { - builder.Append(" nodeVersion:"); + builder.Append(" nodeVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (NodeVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{NodeVersion}'''"); } else { - builder.AppendLine($" '{NodeVersion}'"); + builder.AppendLine($"'{NodeVersion}'"); } } } @@ -2003,21 +2003,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PowerShellVersion), out propertyOverride); if (Optional.IsDefined(PowerShellVersion) || hasPropertyOverride) { - builder.Append(" powerShellVersion:"); + builder.Append(" powerShellVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PowerShellVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PowerShellVersion}'''"); } else { - builder.AppendLine($" '{PowerShellVersion}'"); + builder.AppendLine($"'{PowerShellVersion}'"); } } } @@ -2025,21 +2025,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LinuxFxVersion), out propertyOverride); if (Optional.IsDefined(LinuxFxVersion) || hasPropertyOverride) { - builder.Append(" linuxFxVersion:"); + builder.Append(" linuxFxVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LinuxFxVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LinuxFxVersion}'''"); } else { - builder.AppendLine($" '{LinuxFxVersion}'"); + builder.AppendLine($"'{LinuxFxVersion}'"); } } } @@ -2047,21 +2047,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WindowsFxVersion), out propertyOverride); if (Optional.IsDefined(WindowsFxVersion) || hasPropertyOverride) { - builder.Append(" windowsFxVersion:"); + builder.Append(" windowsFxVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WindowsFxVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WindowsFxVersion}'''"); } else { - builder.AppendLine($" '{WindowsFxVersion}'"); + builder.AppendLine($"'{WindowsFxVersion}'"); } } } @@ -2069,66 +2069,66 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRequestTracingEnabled), out propertyOverride); if (Optional.IsDefined(IsRequestTracingEnabled) || hasPropertyOverride) { - builder.Append(" requestTracingEnabled:"); + builder.Append(" requestTracingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRequestTracingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestTracingExpirationOn), out propertyOverride); if (Optional.IsDefined(RequestTracingExpirationOn) || hasPropertyOverride) { - builder.Append(" requestTracingExpirationTime:"); + builder.Append(" requestTracingExpirationTime: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(RequestTracingExpirationOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRemoteDebuggingEnabled), out propertyOverride); if (Optional.IsDefined(IsRemoteDebuggingEnabled) || hasPropertyOverride) { - builder.Append(" remoteDebuggingEnabled:"); + builder.Append(" remoteDebuggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsRemoteDebuggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RemoteDebuggingVersion), out propertyOverride); if (Optional.IsDefined(RemoteDebuggingVersion) || hasPropertyOverride) { - builder.Append(" remoteDebuggingVersion:"); + builder.Append(" remoteDebuggingVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RemoteDebuggingVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RemoteDebuggingVersion}'''"); } else { - builder.AppendLine($" '{RemoteDebuggingVersion}'"); + builder.AppendLine($"'{RemoteDebuggingVersion}'"); } } } @@ -2136,51 +2136,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttpLoggingEnabled), out propertyOverride); if (Optional.IsDefined(IsHttpLoggingEnabled) || hasPropertyOverride) { - builder.Append(" httpLoggingEnabled:"); + builder.Append(" httpLoggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttpLoggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UseManagedIdentityCreds), out propertyOverride); if (Optional.IsDefined(UseManagedIdentityCreds) || hasPropertyOverride) { - builder.Append(" acrUseManagedIdentityCreds:"); + builder.Append(" acrUseManagedIdentityCreds: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = UseManagedIdentityCreds.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AcrUserManagedIdentityId), out propertyOverride); if (Optional.IsDefined(AcrUserManagedIdentityId) || hasPropertyOverride) { - builder.Append(" acrUserManagedIdentityID:"); + builder.Append(" acrUserManagedIdentityID: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AcrUserManagedIdentityId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AcrUserManagedIdentityId}'''"); } else { - builder.AppendLine($" '{AcrUserManagedIdentityId}'"); + builder.AppendLine($"'{AcrUserManagedIdentityId}'"); } } } @@ -2188,50 +2188,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogsDirectorySizeLimit), out propertyOverride); if (Optional.IsDefined(LogsDirectorySizeLimit) || hasPropertyOverride) { - builder.Append(" logsDirectorySizeLimit:"); + builder.Append(" logsDirectorySizeLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {LogsDirectorySizeLimit.Value}"); + builder.AppendLine($"{LogsDirectorySizeLimit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDetailedErrorLoggingEnabled), out propertyOverride); if (Optional.IsDefined(IsDetailedErrorLoggingEnabled) || hasPropertyOverride) { - builder.Append(" detailedErrorLoggingEnabled:"); + builder.Append(" detailedErrorLoggingEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDetailedErrorLoggingEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishingUsername), out propertyOverride); if (Optional.IsDefined(PublishingUsername) || hasPropertyOverride) { - builder.Append(" publishingUsername:"); + builder.Append(" publishingUsername: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublishingUsername.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublishingUsername}'''"); } else { - builder.AppendLine($" '{PublishingUsername}'"); + builder.AppendLine($"'{PublishingUsername}'"); } } } @@ -2241,17 +2241,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettings.Any() || hasPropertyOverride) { - builder.Append(" appSettings:"); + builder.Append(" appSettings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AppSettings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " appSettings: "); } builder.AppendLine(" ]"); } @@ -2263,17 +2263,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ConnectionStrings.Any() || hasPropertyOverride) { - builder.Append(" connectionStrings:"); + builder.Append(" connectionStrings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ConnectionStrings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " connectionStrings: "); } builder.AppendLine(" ]"); } @@ -2283,14 +2283,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MachineKey), out propertyOverride); if (Optional.IsDefined(MachineKey) || hasPropertyOverride) { - builder.Append(" machineKey:"); + builder.Append(" machineKey: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, MachineKey, options, 4, false); + AppendChildObject(builder, MachineKey, options, 4, false, " machineKey: "); } } @@ -2299,17 +2299,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HandlerMappings.Any() || hasPropertyOverride) { - builder.Append(" handlerMappings:"); + builder.Append(" handlerMappings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HandlerMappings) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " handlerMappings: "); } builder.AppendLine(" ]"); } @@ -2319,21 +2319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DocumentRoot), out propertyOverride); if (Optional.IsDefined(DocumentRoot) || hasPropertyOverride) { - builder.Append(" documentRoot:"); + builder.Append(" documentRoot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DocumentRoot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DocumentRoot}'''"); } else { - builder.AppendLine($" '{DocumentRoot}'"); + builder.AppendLine($"'{DocumentRoot}'"); } } } @@ -2341,80 +2341,80 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScmType), out propertyOverride); if (Optional.IsDefined(ScmType) || hasPropertyOverride) { - builder.Append(" scmType:"); + builder.Append(" scmType: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ScmType.Value.ToString()}'"); + builder.AppendLine($"'{ScmType.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Use32BitWorkerProcess), out propertyOverride); if (Optional.IsDefined(Use32BitWorkerProcess) || hasPropertyOverride) { - builder.Append(" use32BitWorkerProcess:"); + builder.Append(" use32BitWorkerProcess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = Use32BitWorkerProcess.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsWebSocketsEnabled), out propertyOverride); if (Optional.IsDefined(IsWebSocketsEnabled) || hasPropertyOverride) { - builder.Append(" webSocketsEnabled:"); + builder.Append(" webSocketsEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsWebSocketsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAlwaysOn), out propertyOverride); if (Optional.IsDefined(IsAlwaysOn) || hasPropertyOverride) { - builder.Append(" alwaysOn:"); + builder.Append(" alwaysOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAlwaysOn.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaVersion), out propertyOverride); if (Optional.IsDefined(JavaVersion) || hasPropertyOverride) { - builder.Append(" javaVersion:"); + builder.Append(" javaVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaVersion}'''"); } else { - builder.AppendLine($" '{JavaVersion}'"); + builder.AppendLine($"'{JavaVersion}'"); } } } @@ -2422,21 +2422,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainer), out propertyOverride); if (Optional.IsDefined(JavaContainer) || hasPropertyOverride) { - builder.Append(" javaContainer:"); + builder.Append(" javaContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainer}'''"); } else { - builder.AppendLine($" '{JavaContainer}'"); + builder.AppendLine($"'{JavaContainer}'"); } } } @@ -2444,21 +2444,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JavaContainerVersion), out propertyOverride); if (Optional.IsDefined(JavaContainerVersion) || hasPropertyOverride) { - builder.Append(" javaContainerVersion:"); + builder.Append(" javaContainerVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (JavaContainerVersion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{JavaContainerVersion}'''"); } else { - builder.AppendLine($" '{JavaContainerVersion}'"); + builder.AppendLine($"'{JavaContainerVersion}'"); } } } @@ -2466,21 +2466,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppCommandLine), out propertyOverride); if (Optional.IsDefined(AppCommandLine) || hasPropertyOverride) { - builder.Append(" appCommandLine:"); + builder.Append(" appCommandLine: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AppCommandLine.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AppCommandLine}'''"); } else { - builder.AppendLine($" '{AppCommandLine}'"); + builder.AppendLine($"'{AppCommandLine}'"); } } } @@ -2488,14 +2488,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedPipelineMode), out propertyOverride); if (Optional.IsDefined(ManagedPipelineMode) || hasPropertyOverride) { - builder.Append(" managedPipelineMode:"); + builder.Append(" managedPipelineMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ManagedPipelineMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ManagedPipelineMode.Value.ToSerialString()}'"); } } @@ -2504,17 +2504,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (VirtualApplications.Any() || hasPropertyOverride) { - builder.Append(" virtualApplications:"); + builder.Append(" virtualApplications: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in VirtualApplications) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " virtualApplications: "); } builder.AppendLine(" ]"); } @@ -2524,92 +2524,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoadBalancing), out propertyOverride); if (Optional.IsDefined(LoadBalancing) || hasPropertyOverride) { - builder.Append(" loadBalancing:"); + builder.Append(" loadBalancing: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LoadBalancing.Value.ToSerialString()}'"); + builder.AppendLine($"'{LoadBalancing.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Experiments), out propertyOverride); if (Optional.IsDefined(Experiments) || hasPropertyOverride) { - builder.Append(" experiments:"); + builder.Append(" experiments: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Experiments, options, 4, false); + AppendChildObject(builder, Experiments, options, 4, false, " experiments: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limits), out propertyOverride); if (Optional.IsDefined(Limits) || hasPropertyOverride) { - builder.Append(" limits:"); + builder.Append(" limits: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Limits, options, 4, false); + AppendChildObject(builder, Limits, options, 4, false, " limits: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoHealEnabled), out propertyOverride); if (Optional.IsDefined(IsAutoHealEnabled) || hasPropertyOverride) { - builder.Append(" autoHealEnabled:"); + builder.Append(" autoHealEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsAutoHealEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoHealRules), out propertyOverride); if (Optional.IsDefined(AutoHealRules) || hasPropertyOverride) { - builder.Append(" autoHealRules:"); + builder.Append(" autoHealRules: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, AutoHealRules, options, 4, false); + AppendChildObject(builder, AutoHealRules, options, 4, false, " autoHealRules: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TracingOptions), out propertyOverride); if (Optional.IsDefined(TracingOptions) || hasPropertyOverride) { - builder.Append(" tracingOptions:"); + builder.Append(" tracingOptions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TracingOptions.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TracingOptions}'''"); } else { - builder.AppendLine($" '{TracingOptions}'"); + builder.AppendLine($"'{TracingOptions}'"); } } } @@ -2617,21 +2617,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetName), out propertyOverride); if (Optional.IsDefined(VnetName) || hasPropertyOverride) { - builder.Append(" vnetName:"); + builder.Append(" vnetName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (VnetName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{VnetName}'''"); } else { - builder.AppendLine($" '{VnetName}'"); + builder.AppendLine($"'{VnetName}'"); } } } @@ -2639,106 +2639,106 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsVnetRouteAllEnabled), out propertyOverride); if (Optional.IsDefined(IsVnetRouteAllEnabled) || hasPropertyOverride) { - builder.Append(" vnetRouteAllEnabled:"); + builder.Append(" vnetRouteAllEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsVnetRouteAllEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetPrivatePortsCount), out propertyOverride); if (Optional.IsDefined(VnetPrivatePortsCount) || hasPropertyOverride) { - builder.Append(" vnetPrivatePortsCount:"); + builder.Append(" vnetPrivatePortsCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {VnetPrivatePortsCount.Value}"); + builder.AppendLine($"{VnetPrivatePortsCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cors), out propertyOverride); if (Optional.IsDefined(Cors) || hasPropertyOverride) { - builder.Append(" cors:"); + builder.Append(" cors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Cors, options, 4, false); + AppendChildObject(builder, Cors, options, 4, false, " cors: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Push), out propertyOverride); if (Optional.IsDefined(Push) || hasPropertyOverride) { - builder.Append(" push:"); + builder.Append(" push: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Push, options, 4, false); + AppendChildObject(builder, Push, options, 4, false, " push: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiDefinition), out propertyOverride); if (Optional.IsDefined(ApiDefinition) || hasPropertyOverride) { - builder.Append(" apiDefinition:"); + builder.Append(" apiDefinition: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ApiDefinition, options, 4, false); + AppendChildObject(builder, ApiDefinition, options, 4, false, " apiDefinition: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiManagementConfig), out propertyOverride); if (Optional.IsDefined(ApiManagementConfig) || hasPropertyOverride) { - builder.Append(" apiManagementConfig:"); + builder.Append(" apiManagementConfig: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ApiManagementConfig, options, 4, false); + AppendChildObject(builder, ApiManagementConfig, options, 4, false, " apiManagementConfig: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoSwapSlotName), out propertyOverride); if (Optional.IsDefined(AutoSwapSlotName) || hasPropertyOverride) { - builder.Append(" autoSwapSlotName:"); + builder.Append(" autoSwapSlotName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AutoSwapSlotName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AutoSwapSlotName}'''"); } else { - builder.AppendLine($" '{AutoSwapSlotName}'"); + builder.AppendLine($"'{AutoSwapSlotName}'"); } } } @@ -2746,64 +2746,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocalMySqlEnabled), out propertyOverride); if (Optional.IsDefined(IsLocalMySqlEnabled) || hasPropertyOverride) { - builder.Append(" localMySqlEnabled:"); + builder.Append(" localMySqlEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsLocalMySqlEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedServiceIdentityId), out propertyOverride); if (Optional.IsDefined(ManagedServiceIdentityId) || hasPropertyOverride) { - builder.Append(" managedServiceIdentityId:"); + builder.Append(" managedServiceIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ManagedServiceIdentityId.Value}"); + builder.AppendLine($"{ManagedServiceIdentityId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(XManagedServiceIdentityId), out propertyOverride); if (Optional.IsDefined(XManagedServiceIdentityId) || hasPropertyOverride) { - builder.Append(" xManagedServiceIdentityId:"); + builder.Append(" xManagedServiceIdentityId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {XManagedServiceIdentityId.Value}"); + builder.AppendLine($"{XManagedServiceIdentityId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -2813,17 +2813,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (IPSecurityRestrictions.Any() || hasPropertyOverride) { - builder.Append(" ipSecurityRestrictions:"); + builder.Append(" ipSecurityRestrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in IPSecurityRestrictions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " ipSecurityRestrictions: "); } builder.AppendLine(" ]"); } @@ -2835,17 +2835,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ScmIPSecurityRestrictions.Any() || hasPropertyOverride) { - builder.Append(" scmIpSecurityRestrictions:"); + builder.Append(" scmIpSecurityRestrictions: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ScmIPSecurityRestrictions) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " scmIpSecurityRestrictions: "); } builder.AppendLine(" ]"); } @@ -2855,121 +2855,121 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowIPSecurityRestrictionsForScmToUseMain), out propertyOverride); if (Optional.IsDefined(AllowIPSecurityRestrictionsForScmToUseMain) || hasPropertyOverride) { - builder.Append(" scmIpSecurityRestrictionsUseMain:"); + builder.Append(" scmIpSecurityRestrictionsUseMain: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowIPSecurityRestrictionsForScmToUseMain.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttp20Enabled), out propertyOverride); if (Optional.IsDefined(IsHttp20Enabled) || hasPropertyOverride) { - builder.Append(" http20Enabled:"); + builder.Append(" http20Enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttp20Enabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinTlsVersion), out propertyOverride); if (Optional.IsDefined(MinTlsVersion) || hasPropertyOverride) { - builder.Append(" minTlsVersion:"); + builder.Append(" minTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{MinTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{MinTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScmMinTlsVersion), out propertyOverride); if (Optional.IsDefined(ScmMinTlsVersion) || hasPropertyOverride) { - builder.Append(" scmMinTlsVersion:"); + builder.Append(" scmMinTlsVersion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ScmMinTlsVersion.Value.ToString()}'"); + builder.AppendLine($"'{ScmMinTlsVersion.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FtpsState), out propertyOverride); if (Optional.IsDefined(FtpsState) || hasPropertyOverride) { - builder.Append(" ftpsState:"); + builder.Append(" ftpsState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FtpsState.Value.ToString()}'"); + builder.AppendLine($"'{FtpsState.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreWarmedInstanceCount), out propertyOverride); if (Optional.IsDefined(PreWarmedInstanceCount) || hasPropertyOverride) { - builder.Append(" preWarmedInstanceCount:"); + builder.Append(" preWarmedInstanceCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {PreWarmedInstanceCount.Value}"); + builder.AppendLine($"{PreWarmedInstanceCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAppScaleLimit), out propertyOverride); if (Optional.IsDefined(FunctionAppScaleLimit) || hasPropertyOverride) { - builder.Append(" functionAppScaleLimit:"); + builder.Append(" functionAppScaleLimit: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {FunctionAppScaleLimit.Value}"); + builder.AppendLine($"{FunctionAppScaleLimit.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HealthCheckPath), out propertyOverride); if (Optional.IsDefined(HealthCheckPath) || hasPropertyOverride) { - builder.Append(" healthCheckPath:"); + builder.Append(" healthCheckPath: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HealthCheckPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HealthCheckPath}'''"); } else { - builder.AppendLine($" '{HealthCheckPath}'"); + builder.AppendLine($"'{HealthCheckPath}'"); } } } @@ -2977,36 +2977,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsFunctionsRuntimeScaleMonitoringEnabled), out propertyOverride); if (Optional.IsDefined(IsFunctionsRuntimeScaleMonitoringEnabled) || hasPropertyOverride) { - builder.Append(" functionsRuntimeScaleMonitoringEnabled:"); + builder.Append(" functionsRuntimeScaleMonitoringEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsFunctionsRuntimeScaleMonitoringEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebsiteTimeZone), out propertyOverride); if (Optional.IsDefined(WebsiteTimeZone) || hasPropertyOverride) { - builder.Append(" websiteTimeZone:"); + builder.Append(" websiteTimeZone: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (WebsiteTimeZone.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{WebsiteTimeZone}'''"); } else { - builder.AppendLine($" '{WebsiteTimeZone}'"); + builder.AppendLine($"'{WebsiteTimeZone}'"); } } } @@ -3014,14 +3014,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumElasticInstanceCount), out propertyOverride); if (Optional.IsDefined(MinimumElasticInstanceCount) || hasPropertyOverride) { - builder.Append(" minimumElasticInstanceCount:"); + builder.Append(" minimumElasticInstanceCount: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MinimumElasticInstanceCount.Value}"); + builder.AppendLine($"{MinimumElasticInstanceCount.Value}"); } } @@ -3030,18 +3030,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AzureStorageAccounts.Any() || hasPropertyOverride) { - builder.Append(" azureStorageAccounts:"); + builder.Append(" azureStorageAccounts: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in AzureStorageAccounts) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " azureStorageAccounts: "); } builder.AppendLine(" }"); } @@ -3051,21 +3051,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) { - builder.Append(" publicNetworkAccess:"); + builder.Append(" publicNetworkAccess: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PublicNetworkAccess.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PublicNetworkAccess}'''"); } else { - builder.AppendLine($" '{PublicNetworkAccess}'"); + builder.AppendLine($"'{PublicNetworkAccess}'"); } } } @@ -3075,12 +3075,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -3101,13 +3104,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteExtensionInfoData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteExtensionInfoData.Serialization.cs index 258c48729883d..dbf51db85206d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteExtensionInfoData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteExtensionInfoData.Serialization.cs @@ -444,21 +444,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -466,21 +466,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -488,28 +488,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -518,21 +518,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtensionId), out propertyOverride); if (Optional.IsDefined(ExtensionId) || hasPropertyOverride) { - builder.Append(" extension_id:"); + builder.Append(" extension_id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ExtensionId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ExtensionId}'''"); } else { - builder.AppendLine($" '{ExtensionId}'"); + builder.AppendLine($"'{ExtensionId}'"); } } } @@ -540,21 +540,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); if (Optional.IsDefined(Title) || hasPropertyOverride) { - builder.Append(" title:"); + builder.Append(" title: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Title.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Title}'''"); } else { - builder.AppendLine($" '{Title}'"); + builder.AppendLine($"'{Title}'"); } } } @@ -562,35 +562,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtensionType), out propertyOverride); if (Optional.IsDefined(ExtensionType) || hasPropertyOverride) { - builder.Append(" extension_type:"); + builder.Append(" extension_type: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExtensionType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ExtensionType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Summary), out propertyOverride); if (Optional.IsDefined(Summary) || hasPropertyOverride) { - builder.Append(" summary:"); + builder.Append(" summary: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Summary.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Summary}'''"); } else { - builder.AppendLine($" '{Summary}'"); + builder.AppendLine($"'{Summary}'"); } } } @@ -598,21 +598,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -620,21 +620,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); if (Optional.IsDefined(Version) || hasPropertyOverride) { - builder.Append(" version:"); + builder.Append(" version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Version.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Version}'''"); } else { - builder.AppendLine($" '{Version}'"); + builder.AppendLine($"'{Version}'"); } } } @@ -642,70 +642,70 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtensionUri), out propertyOverride); if (Optional.IsDefined(ExtensionUri) || hasPropertyOverride) { - builder.Append(" extension_url:"); + builder.Append(" extension_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExtensionUri.AbsoluteUri}'"); + builder.AppendLine($"'{ExtensionUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProjectUri), out propertyOverride); if (Optional.IsDefined(ProjectUri) || hasPropertyOverride) { - builder.Append(" project_url:"); + builder.Append(" project_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ProjectUri.AbsoluteUri}'"); + builder.AppendLine($"'{ProjectUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IconUri), out propertyOverride); if (Optional.IsDefined(IconUri) || hasPropertyOverride) { - builder.Append(" icon_url:"); + builder.Append(" icon_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{IconUri.AbsoluteUri}'"); + builder.AppendLine($"'{IconUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LicenseUri), out propertyOverride); if (Optional.IsDefined(LicenseUri) || hasPropertyOverride) { - builder.Append(" license_url:"); + builder.Append(" license_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{LicenseUri.AbsoluteUri}'"); + builder.AppendLine($"'{LicenseUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FeedUri), out propertyOverride); if (Optional.IsDefined(FeedUri) || hasPropertyOverride) { - builder.Append(" feed_url:"); + builder.Append(" feed_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FeedUri.AbsoluteUri}'"); + builder.AppendLine($"'{FeedUri.AbsoluteUri}'"); } } @@ -714,14 +714,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Authors.Any() || hasPropertyOverride) { - builder.Append(" authors:"); + builder.Append(" authors: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Authors) { if (item == null) @@ -747,21 +747,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InstallerCommandLineParams), out propertyOverride); if (Optional.IsDefined(InstallerCommandLineParams) || hasPropertyOverride) { - builder.Append(" installer_command_line_params:"); + builder.Append(" installer_command_line_params: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (InstallerCommandLineParams.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{InstallerCommandLineParams}'''"); } else { - builder.AppendLine($" '{InstallerCommandLineParams}'"); + builder.AppendLine($"'{InstallerCommandLineParams}'"); } } } @@ -769,65 +769,65 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishedOn), out propertyOverride); if (Optional.IsDefined(PublishedOn) || hasPropertyOverride) { - builder.Append(" published_date_time:"); + builder.Append(" published_date_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(PublishedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DownloadCount), out propertyOverride); if (Optional.IsDefined(DownloadCount) || hasPropertyOverride) { - builder.Append(" download_count:"); + builder.Append(" download_count: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DownloadCount.Value}"); + builder.AppendLine($"{DownloadCount.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalIsLatestVersion), out propertyOverride); if (Optional.IsDefined(LocalIsLatestVersion) || hasPropertyOverride) { - builder.Append(" local_is_latest_version:"); + builder.Append(" local_is_latest_version: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = LocalIsLatestVersion.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalPath), out propertyOverride); if (Optional.IsDefined(LocalPath) || hasPropertyOverride) { - builder.Append(" local_path:"); + builder.Append(" local_path: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (LocalPath.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{LocalPath}'''"); } else { - builder.AppendLine($" '{LocalPath}'"); + builder.AppendLine($"'{LocalPath}'"); } } } @@ -835,36 +835,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InstalledOn), out propertyOverride); if (Optional.IsDefined(InstalledOn) || hasPropertyOverride) { - builder.Append(" installed_date_time:"); + builder.Append(" installed_date_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(InstalledOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) { - builder.Append(" provisioningState:"); + builder.Append(" provisioningState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ProvisioningState.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ProvisioningState}'''"); } else { - builder.AppendLine($" '{ProvisioningState}'"); + builder.AppendLine($"'{ProvisioningState}'"); } } } @@ -872,21 +872,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Comment), out propertyOverride); if (Optional.IsDefined(Comment) || hasPropertyOverride) { - builder.Append(" comment:"); + builder.Append(" comment: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Comment.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Comment}'''"); } else { - builder.AppendLine($" '{Comment}'"); + builder.AppendLine($"'{Comment}'"); } } } @@ -896,12 +896,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -922,13 +925,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteLogsConfigData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteLogsConfigData.Serialization.cs index adbbd89525262..ca21a3b092b38 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteLogsConfigData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteLogsConfigData.Serialization.cs @@ -229,21 +229,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -251,21 +251,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -273,28 +273,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -303,56 +303,56 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationLogs), out propertyOverride); if (Optional.IsDefined(ApplicationLogs) || hasPropertyOverride) { - builder.Append(" applicationLogs:"); + builder.Append(" applicationLogs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ApplicationLogs, options, 4, false); + AppendChildObject(builder, ApplicationLogs, options, 4, false, " applicationLogs: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpLogs), out propertyOverride); if (Optional.IsDefined(HttpLogs) || hasPropertyOverride) { - builder.Append(" httpLogs:"); + builder.Append(" httpLogs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HttpLogs, options, 4, false); + AppendChildObject(builder, HttpLogs, options, 4, false, " httpLogs: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsFailedRequestsTracing), out propertyOverride); if (Optional.IsDefined(IsFailedRequestsTracing) || hasPropertyOverride) { - builder.Append(" failedRequestsTracing:"); + builder.Append(" failedRequestsTracing: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IsFailedRequestsTracing, options, 4, false); + AppendChildObject(builder, IsFailedRequestsTracing, options, 4, false, " failedRequestsTracing: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDetailedErrorMessages), out propertyOverride); if (Optional.IsDefined(IsDetailedErrorMessages) || hasPropertyOverride) { - builder.Append(" detailedErrorMessages:"); + builder.Append(" detailedErrorMessages: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, IsDetailedErrorMessages, options, 4, false); + AppendChildObject(builder, IsDetailedErrorMessages, options, 4, false, " detailedErrorMessages: "); } } @@ -361,12 +361,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -387,13 +390,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteSourceControlData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteSourceControlData.Serialization.cs index bcc943b726c95..b5b3a329e5669 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteSourceControlData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SiteSourceControlData.Serialization.cs @@ -278,21 +278,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -300,21 +300,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -322,28 +322,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -352,35 +352,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepoUri), out propertyOverride); if (Optional.IsDefined(RepoUri) || hasPropertyOverride) { - builder.Append(" repoUrl:"); + builder.Append(" repoUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RepoUri.AbsoluteUri}'"); + builder.AppendLine($"'{RepoUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); if (Optional.IsDefined(Branch) || hasPropertyOverride) { - builder.Append(" branch:"); + builder.Append(" branch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Branch.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Branch}'''"); } else { - builder.AppendLine($" '{Branch}'"); + builder.AppendLine($"'{Branch}'"); } } } @@ -388,74 +388,74 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsManualIntegration), out propertyOverride); if (Optional.IsDefined(IsManualIntegration) || hasPropertyOverride) { - builder.Append(" isManualIntegration:"); + builder.Append(" isManualIntegration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsManualIntegration.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsGitHubAction), out propertyOverride); if (Optional.IsDefined(IsGitHubAction) || hasPropertyOverride) { - builder.Append(" isGitHubAction:"); + builder.Append(" isGitHubAction: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsGitHubAction.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDeploymentRollbackEnabled), out propertyOverride); if (Optional.IsDefined(IsDeploymentRollbackEnabled) || hasPropertyOverride) { - builder.Append(" deploymentRollbackEnabled:"); + builder.Append(" deploymentRollbackEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDeploymentRollbackEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMercurial), out propertyOverride); if (Optional.IsDefined(IsMercurial) || hasPropertyOverride) { - builder.Append(" isMercurial:"); + builder.Append(" isMercurial: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsMercurial.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubActionConfiguration), out propertyOverride); if (Optional.IsDefined(GitHubActionConfiguration) || hasPropertyOverride) { - builder.Append(" gitHubActionConfiguration:"); + builder.Append(" gitHubActionConfiguration: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, GitHubActionConfiguration, options, 4, false); + AppendChildObject(builder, GitHubActionConfiguration, options, 4, false, " gitHubActionConfiguration: "); } } @@ -464,12 +464,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -490,13 +493,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SlotConfigNamesResourceData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SlotConfigNamesResourceData.Serialization.cs index 4f9a3186548f1..1abc7457383a4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SlotConfigNamesResourceData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SlotConfigNamesResourceData.Serialization.cs @@ -244,21 +244,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -266,21 +266,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -288,28 +288,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -320,14 +320,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (ConnectionStringNames.Any() || hasPropertyOverride) { - builder.Append(" connectionStringNames:"); + builder.Append(" connectionStringNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in ConnectionStringNames) { if (item == null) @@ -355,14 +355,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AppSettingNames.Any() || hasPropertyOverride) { - builder.Append(" appSettingNames:"); + builder.Append(" appSettingNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AppSettingNames) { if (item == null) @@ -390,14 +390,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (AzureStorageConfigNames.Any() || hasPropertyOverride) { - builder.Append(" azureStorageConfigNames:"); + builder.Append(" azureStorageConfigNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in AzureStorageConfigNames) { if (item == null) @@ -425,12 +425,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -451,13 +454,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteBuildData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteBuildData.Serialization.cs index 1553cd01a57e8..714f29ea8168b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteBuildData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteBuildData.Serialization.cs @@ -284,21 +284,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -306,21 +306,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -328,28 +328,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -358,21 +358,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BuildId), out propertyOverride); if (Optional.IsDefined(BuildId) || hasPropertyOverride) { - builder.Append(" buildId:"); + builder.Append(" buildId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BuildId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BuildId}'''"); } else { - builder.AppendLine($" '{BuildId}'"); + builder.AppendLine($"'{BuildId}'"); } } } @@ -380,21 +380,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceBranch), out propertyOverride); if (Optional.IsDefined(SourceBranch) || hasPropertyOverride) { - builder.Append(" sourceBranch:"); + builder.Append(" sourceBranch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (SourceBranch.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{SourceBranch}'''"); } else { - builder.AppendLine($" '{SourceBranch}'"); + builder.AppendLine($"'{SourceBranch}'"); } } } @@ -402,21 +402,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PullRequestTitle), out propertyOverride); if (Optional.IsDefined(PullRequestTitle) || hasPropertyOverride) { - builder.Append(" pullRequestTitle:"); + builder.Append(" pullRequestTitle: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PullRequestTitle.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PullRequestTitle}'''"); } else { - builder.AppendLine($" '{PullRequestTitle}'"); + builder.AppendLine($"'{PullRequestTitle}'"); } } } @@ -424,21 +424,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Hostname), out propertyOverride); if (Optional.IsDefined(Hostname) || hasPropertyOverride) { - builder.Append(" hostname:"); + builder.Append(" hostname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Hostname.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Hostname}'''"); } else { - builder.AppendLine($" '{Hostname}'"); + builder.AppendLine($"'{Hostname}'"); } } } @@ -446,44 +446,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdTimeUtc:"); + builder.Append(" createdTimeUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUpdatedOn), out propertyOverride); if (Optional.IsDefined(LastUpdatedOn) || hasPropertyOverride) { - builder.Append(" lastUpdatedOn:"); + builder.Append(" lastUpdatedOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastUpdatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } @@ -492,17 +492,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserProvidedFunctionApps.Any() || hasPropertyOverride) { - builder.Append(" userProvidedFunctionApps:"); + builder.Append(" userProvidedFunctionApps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserProvidedFunctionApps) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " userProvidedFunctionApps: "); } builder.AppendLine(" ]"); } @@ -514,12 +514,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -540,13 +543,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteCustomDomainOverviewData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteCustomDomainOverviewData.Serialization.cs index 2ca089db98523..d6844a65c2a8e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteCustomDomainOverviewData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteCustomDomainOverviewData.Serialization.cs @@ -232,21 +232,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -254,21 +254,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -276,28 +276,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -306,21 +306,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainName), out propertyOverride); if (Optional.IsDefined(DomainName) || hasPropertyOverride) { - builder.Append(" domainName:"); + builder.Append(" domainName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DomainName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DomainName}'''"); } else { - builder.AppendLine($" '{DomainName}'"); + builder.AppendLine($"'{DomainName}'"); } } } @@ -328,50 +328,50 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdOn:"); + builder.Append(" createdOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToString()}'"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidationToken), out propertyOverride); if (Optional.IsDefined(ValidationToken) || hasPropertyOverride) { - builder.Append(" validationToken:"); + builder.Append(" validationToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ValidationToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ValidationToken}'''"); } else { - builder.AppendLine($" '{ValidationToken}'"); + builder.AppendLine($"'{ValidationToken}'"); } } } @@ -379,21 +379,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ErrorMessage), out propertyOverride); if (Optional.IsDefined(ErrorMessage) || hasPropertyOverride) { - builder.Append(" errorMessage:"); + builder.Append(" errorMessage: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ErrorMessage.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ErrorMessage}'''"); } else { - builder.AppendLine($" '{ErrorMessage}'"); + builder.AppendLine($"'{ErrorMessage}'"); } } } @@ -403,12 +403,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -429,13 +432,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteData.Serialization.cs index 31c96e0e42f7b..177ab88a027bb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteData.Serialization.cs @@ -450,21 +450,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -472,14 +472,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -488,17 +488,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -506,12 +506,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -522,49 +522,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (Optional.IsDefined(Sku) || hasPropertyOverride) { - builder.Append(" sku:"); + builder.Append(" sku: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Sku, options, 2, false); + AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -572,28 +572,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -602,21 +602,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultHostname), out propertyOverride); if (Optional.IsDefined(DefaultHostname) || hasPropertyOverride) { - builder.Append(" defaultHostname:"); + builder.Append(" defaultHostname: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultHostname.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultHostname}'''"); } else { - builder.AppendLine($" '{DefaultHostname}'"); + builder.AppendLine($"'{DefaultHostname}'"); } } } @@ -624,35 +624,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryUri), out propertyOverride); if (Optional.IsDefined(RepositoryUri) || hasPropertyOverride) { - builder.Append(" repositoryUrl:"); + builder.Append(" repositoryUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RepositoryUri.AbsoluteUri}'"); + builder.AppendLine($"'{RepositoryUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); if (Optional.IsDefined(Branch) || hasPropertyOverride) { - builder.Append(" branch:"); + builder.Append(" branch: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Branch.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Branch}'''"); } else { - builder.AppendLine($" '{Branch}'"); + builder.AppendLine($"'{Branch}'"); } } } @@ -662,14 +662,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (CustomDomains.Any() || hasPropertyOverride) { - builder.Append(" customDomains:"); + builder.Append(" customDomains: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in CustomDomains) { if (item == null) @@ -695,21 +695,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryToken), out propertyOverride); if (Optional.IsDefined(RepositoryToken) || hasPropertyOverride) { - builder.Append(" repositoryToken:"); + builder.Append(" repositoryToken: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositoryToken.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositoryToken}'''"); } else { - builder.AppendLine($" '{RepositoryToken}'"); + builder.AppendLine($"'{RepositoryToken}'"); } } } @@ -717,14 +717,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BuildProperties), out propertyOverride); if (Optional.IsDefined(BuildProperties) || hasPropertyOverride) { - builder.Append(" buildProperties:"); + builder.Append(" buildProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, BuildProperties, options, 4, false); + AppendChildObject(builder, BuildProperties, options, 4, false, " buildProperties: "); } } @@ -733,17 +733,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (PrivateEndpointConnections.Any() || hasPropertyOverride) { - builder.Append(" privateEndpointConnections:"); + builder.Append(" privateEndpointConnections: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in PrivateEndpointConnections) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); } builder.AppendLine(" ]"); } @@ -753,64 +753,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StagingEnvironmentPolicy), out propertyOverride); if (Optional.IsDefined(StagingEnvironmentPolicy) || hasPropertyOverride) { - builder.Append(" stagingEnvironmentPolicy:"); + builder.Append(" stagingEnvironmentPolicy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StagingEnvironmentPolicy.Value.ToSerialString()}'"); + builder.AppendLine($"'{StagingEnvironmentPolicy.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowConfigFileUpdates), out propertyOverride); if (Optional.IsDefined(AllowConfigFileUpdates) || hasPropertyOverride) { - builder.Append(" allowConfigFileUpdates:"); + builder.Append(" allowConfigFileUpdates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = AllowConfigFileUpdates.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TemplateProperties), out propertyOverride); if (Optional.IsDefined(TemplateProperties) || hasPropertyOverride) { - builder.Append(" templateProperties:"); + builder.Append(" templateProperties: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, TemplateProperties, options, 4, false); + AppendChildObject(builder, TemplateProperties, options, 4, false, " templateProperties: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentDistributionEndpoint), out propertyOverride); if (Optional.IsDefined(ContentDistributionEndpoint) || hasPropertyOverride) { - builder.Append(" contentDistributionEndpoint:"); + builder.Append(" contentDistributionEndpoint: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ContentDistributionEndpoint.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ContentDistributionEndpoint}'''"); } else { - builder.AppendLine($" '{ContentDistributionEndpoint}'"); + builder.AppendLine($"'{ContentDistributionEndpoint}'"); } } } @@ -818,21 +818,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -842,17 +842,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (UserProvidedFunctionApps.Any() || hasPropertyOverride) { - builder.Append(" userProvidedFunctionApps:"); + builder.Append(" userProvidedFunctionApps: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in UserProvidedFunctionApps) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " userProvidedFunctionApps: "); } builder.AppendLine(" ]"); } @@ -862,21 +862,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Provider), out propertyOverride); if (Optional.IsDefined(Provider) || hasPropertyOverride) { - builder.Append(" provider:"); + builder.Append(" provider: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Provider.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Provider}'''"); } else { - builder.AppendLine($" '{Provider}'"); + builder.AppendLine($"'{Provider}'"); } } } @@ -886,12 +886,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -912,13 +915,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteUserProvidedFunctionAppData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteUserProvidedFunctionAppData.Serialization.cs index f482bca9a4d28..4567ad512c5b9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteUserProvidedFunctionAppData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/StaticSiteUserProvidedFunctionAppData.Serialization.cs @@ -209,21 +209,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -231,21 +231,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -253,28 +253,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -283,35 +283,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAppResourceId), out propertyOverride); if (Optional.IsDefined(FunctionAppResourceId) || hasPropertyOverride) { - builder.Append(" functionAppResourceId:"); + builder.Append(" functionAppResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{FunctionAppResourceId.ToString()}'"); + builder.AppendLine($"'{FunctionAppResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAppRegion), out propertyOverride); if (Optional.IsDefined(FunctionAppRegion) || hasPropertyOverride) { - builder.Append(" functionAppRegion:"); + builder.Append(" functionAppRegion: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (FunctionAppRegion.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{FunctionAppRegion}'''"); } else { - builder.AppendLine($" '{FunctionAppRegion}'"); + builder.AppendLine($"'{FunctionAppRegion}'"); } } } @@ -319,15 +319,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" createdOn:"); + builder.Append(" createdOn: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } @@ -336,12 +336,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -362,13 +365,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SwiftVirtualNetworkData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SwiftVirtualNetworkData.Serialization.cs index eb00b1d52c8d0..6e1cac809f27c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SwiftVirtualNetworkData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/SwiftVirtualNetworkData.Serialization.cs @@ -198,21 +198,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -220,21 +220,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -242,28 +242,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -272,29 +272,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetResourceId), out propertyOverride); if (Optional.IsDefined(SubnetResourceId) || hasPropertyOverride) { - builder.Append(" subnetResourceId:"); + builder.Append(" subnetResourceId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SubnetResourceId.ToString()}'"); + builder.AppendLine($"'{SubnetResourceId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSwiftSupported), out propertyOverride); if (Optional.IsDefined(IsSwiftSupported) || hasPropertyOverride) { - builder.Append(" swiftSupported:"); + builder.Append(" swiftSupported: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsSwiftSupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -303,12 +303,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -329,13 +332,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TopLevelDomainData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TopLevelDomainData.Serialization.cs index 8d584ab03b8f7..0d95b3b6f161b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TopLevelDomainData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TopLevelDomainData.Serialization.cs @@ -183,21 +183,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -205,21 +205,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -227,28 +227,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -257,15 +257,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDomainPrivacySupported), out propertyOverride); if (Optional.IsDefined(IsDomainPrivacySupported) || hasPropertyOverride) { - builder.Append(" privacy:"); + builder.Append(" privacy: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDomainPrivacySupported.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -274,12 +274,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -300,13 +303,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredJobHistoryData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredJobHistoryData.Serialization.cs index d17b0e3c25897..933d2f2128c76 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredJobHistoryData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredJobHistoryData.Serialization.cs @@ -195,21 +195,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -217,21 +217,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -239,28 +239,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -271,17 +271,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Runs.Any() || hasPropertyOverride) { - builder.Append(" runs:"); + builder.Append(" runs: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Runs) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " runs: "); } builder.AppendLine(" ]"); } @@ -293,12 +293,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -319,13 +322,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredWebJobData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredWebJobData.Serialization.cs index 9dbce37f498bb..16af396f6ce9a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredWebJobData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/TriggeredWebJobData.Serialization.cs @@ -342,21 +342,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -364,21 +364,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -386,28 +386,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -416,63 +416,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LatestRun), out propertyOverride); if (Optional.IsDefined(LatestRun) || hasPropertyOverride) { - builder.Append(" latest_run:"); + builder.Append(" latest_run: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, LatestRun, options, 4, false); + AppendChildObject(builder, LatestRun, options, 4, false, " latest_run: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HistoryUri), out propertyOverride); if (Optional.IsDefined(HistoryUri) || hasPropertyOverride) { - builder.Append(" history_url:"); + builder.Append(" history_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{HistoryUri.AbsoluteUri}'"); + builder.AppendLine($"'{HistoryUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SchedulerLogsUri), out propertyOverride); if (Optional.IsDefined(SchedulerLogsUri) || hasPropertyOverride) { - builder.Append(" scheduler_logs_url:"); + builder.Append(" scheduler_logs_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SchedulerLogsUri.AbsoluteUri}'"); + builder.AppendLine($"'{SchedulerLogsUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunCommand), out propertyOverride); if (Optional.IsDefined(RunCommand) || hasPropertyOverride) { - builder.Append(" run_command:"); + builder.Append(" run_command: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RunCommand.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RunCommand}'''"); } else { - builder.AppendLine($" '{RunCommand}'"); + builder.AppendLine($"'{RunCommand}'"); } } } @@ -480,63 +480,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtraInfoUri), out propertyOverride); if (Optional.IsDefined(ExtraInfoUri) || hasPropertyOverride) { - builder.Append(" extra_info_url:"); + builder.Append(" extra_info_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExtraInfoUri.AbsoluteUri}'"); + builder.AppendLine($"'{ExtraInfoUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebJobType), out propertyOverride); if (Optional.IsDefined(WebJobType) || hasPropertyOverride) { - builder.Append(" web_job_type:"); + builder.Append(" web_job_type: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebJobType.Value.ToSerialString()}'"); + builder.AppendLine($"'{WebJobType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Error.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Error}'''"); } else { - builder.AppendLine($" '{Error}'"); + builder.AppendLine($"'{Error}'"); } } } @@ -544,15 +544,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUsingSdk), out propertyOverride); if (Optional.IsDefined(IsUsingSdk) || hasPropertyOverride) { - builder.Append(" using_sdk:"); + builder.Append(" using_sdk: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUsingSdk.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -561,23 +561,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Settings.Any() || hasPropertyOverride) { - builder.Append(" settings:"); + builder.Append(" settings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Settings) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -589,12 +589,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -615,13 +618,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppBackupData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppBackupData.Serialization.cs index 3f1592a595434..ce5fd2976e4be 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppBackupData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppBackupData.Serialization.cs @@ -374,21 +374,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -396,21 +396,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -418,28 +418,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -448,49 +448,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupId), out propertyOverride); if (Optional.IsDefined(BackupId) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {BackupId.Value}"); + builder.AppendLine($"{BackupId.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountUri), out propertyOverride); if (Optional.IsDefined(StorageAccountUri) || hasPropertyOverride) { - builder.Append(" storageAccountUrl:"); + builder.Append(" storageAccountUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StorageAccountUri.AbsoluteUri}'"); + builder.AppendLine($"'{StorageAccountUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlobName), out propertyOverride); if (Optional.IsDefined(BlobName) || hasPropertyOverride) { - builder.Append(" blobName:"); + builder.Append(" blobName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BlobName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BlobName}'''"); } else { - builder.AppendLine($" '{BlobName}'"); + builder.AppendLine($"'{BlobName}'"); } } } @@ -498,21 +498,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupName), out propertyOverride); if (Optional.IsDefined(BackupName) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (BackupName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{BackupName}'''"); } else { - builder.AppendLine($" '{BackupName}'"); + builder.AppendLine($"'{BackupName}'"); } } } @@ -520,64 +520,64 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Status.Value.ToSerialString()}'"); + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SizeInBytes), out propertyOverride); if (Optional.IsDefined(SizeInBytes) || hasPropertyOverride) { - builder.Append(" sizeInBytes:"); + builder.Append(" sizeInBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SizeInBytes.Value.ToString()}'"); + builder.AppendLine($"'{SizeInBytes.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) { - builder.Append(" created:"); + builder.Append(" created: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Log), out propertyOverride); if (Optional.IsDefined(Log) || hasPropertyOverride) { - builder.Append(" log:"); + builder.Append(" log: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Log.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Log}'''"); } else { - builder.AppendLine($" '{Log}'"); + builder.AppendLine($"'{Log}'"); } } } @@ -587,17 +587,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Databases.Any() || hasPropertyOverride) { - builder.Append(" databases:"); + builder.Append(" databases: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in Databases) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " databases: "); } builder.AppendLine(" ]"); } @@ -607,66 +607,66 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsScheduled), out propertyOverride); if (Optional.IsDefined(IsScheduled) || hasPropertyOverride) { - builder.Append(" scheduled:"); + builder.Append(" scheduled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsScheduled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastRestoreOn), out propertyOverride); if (Optional.IsDefined(LastRestoreOn) || hasPropertyOverride) { - builder.Append(" lastRestoreTimeStamp:"); + builder.Append(" lastRestoreTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastRestoreOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FinishedOn), out propertyOverride); if (Optional.IsDefined(FinishedOn) || hasPropertyOverride) { - builder.Append(" finishedTimeStamp:"); + builder.Append(" finishedTimeStamp: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(FinishedOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CorrelationId), out propertyOverride); if (Optional.IsDefined(CorrelationId) || hasPropertyOverride) { - builder.Append(" correlationId:"); + builder.Append(" correlationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CorrelationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CorrelationId}'''"); } else { - builder.AppendLine($" '{CorrelationId}'"); + builder.AppendLine($"'{CorrelationId}'"); } } } @@ -674,14 +674,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebsiteSizeInBytes), out propertyOverride); if (Optional.IsDefined(WebsiteSizeInBytes) || hasPropertyOverride) { - builder.Append(" websiteSizeInBytes:"); + builder.Append(" websiteSizeInBytes: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebsiteSizeInBytes.Value.ToString()}'"); + builder.AppendLine($"'{WebsiteSizeInBytes.Value.ToString()}'"); } } @@ -690,12 +690,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -716,13 +719,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppDeploymentData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppDeploymentData.Serialization.cs index b0a44dc1533d4..16baca7f445c2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppDeploymentData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebAppDeploymentData.Serialization.cs @@ -283,21 +283,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -305,21 +305,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -327,28 +327,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -357,35 +357,35 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { - builder.Append(" status:"); + builder.Append(" status: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {Status.Value}"); + builder.AppendLine($"{Status.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); if (Optional.IsDefined(Message) || hasPropertyOverride) { - builder.Append(" message:"); + builder.Append(" message: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Message.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Message}'''"); } else { - builder.AppendLine($" '{Message}'"); + builder.AppendLine($"'{Message}'"); } } } @@ -393,21 +393,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Author), out propertyOverride); if (Optional.IsDefined(Author) || hasPropertyOverride) { - builder.Append(" author:"); + builder.Append(" author: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Author.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Author}'''"); } else { - builder.AppendLine($" '{Author}'"); + builder.AppendLine($"'{Author}'"); } } } @@ -415,21 +415,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Deployer), out propertyOverride); if (Optional.IsDefined(Deployer) || hasPropertyOverride) { - builder.Append(" deployer:"); + builder.Append(" deployer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Deployer.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Deployer}'''"); } else { - builder.AppendLine($" '{Deployer}'"); + builder.AppendLine($"'{Deployer}'"); } } } @@ -437,21 +437,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthorEmail), out propertyOverride); if (Optional.IsDefined(AuthorEmail) || hasPropertyOverride) { - builder.Append(" author_email:"); + builder.Append(" author_email: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (AuthorEmail.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{AuthorEmail}'''"); } else { - builder.AppendLine($" '{AuthorEmail}'"); + builder.AppendLine($"'{AuthorEmail}'"); } } } @@ -459,66 +459,66 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); if (Optional.IsDefined(StartOn) || hasPropertyOverride) { - builder.Append(" start_time:"); + builder.Append(" start_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); if (Optional.IsDefined(EndOn) || hasPropertyOverride) { - builder.Append(" end_time:"); + builder.Append(" end_time: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsActive), out propertyOverride); if (Optional.IsDefined(IsActive) || hasPropertyOverride) { - builder.Append(" active:"); + builder.Append(" active: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsActive.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); if (Optional.IsDefined(Details) || hasPropertyOverride) { - builder.Append(" details:"); + builder.Append(" details: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Details.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Details}'''"); } else { - builder.AppendLine($" '{Details}'"); + builder.AppendLine($"'{Details}'"); } } } @@ -528,12 +528,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -554,13 +557,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebJobData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebJobData.Serialization.cs index 0c868e97bea94..4e253b0a7fc47 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebJobData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebJobData.Serialization.cs @@ -297,21 +297,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -319,21 +319,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -341,28 +341,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -371,21 +371,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunCommand), out propertyOverride); if (Optional.IsDefined(RunCommand) || hasPropertyOverride) { - builder.Append(" run_command:"); + builder.Append(" run_command: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RunCommand.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RunCommand}'''"); } else { - builder.AppendLine($" '{RunCommand}'"); + builder.AppendLine($"'{RunCommand}'"); } } } @@ -393,63 +393,63 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); if (Optional.IsDefined(Uri) || hasPropertyOverride) { - builder.Append(" url:"); + builder.Append(" url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Uri.AbsoluteUri}'"); + builder.AppendLine($"'{Uri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtraInfoUri), out propertyOverride); if (Optional.IsDefined(ExtraInfoUri) || hasPropertyOverride) { - builder.Append(" extra_info_url:"); + builder.Append(" extra_info_url: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ExtraInfoUri.AbsoluteUri}'"); + builder.AppendLine($"'{ExtraInfoUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WebJobType), out propertyOverride); if (Optional.IsDefined(WebJobType) || hasPropertyOverride) { - builder.Append(" web_job_type:"); + builder.Append(" web_job_type: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{WebJobType.Value.ToSerialString()}'"); + builder.AppendLine($"'{WebJobType.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); if (Optional.IsDefined(Error) || hasPropertyOverride) { - builder.Append(" error:"); + builder.Append(" error: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Error.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Error}'''"); } else { - builder.AppendLine($" '{Error}'"); + builder.AppendLine($"'{Error}'"); } } } @@ -457,15 +457,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsUsingSdk), out propertyOverride); if (Optional.IsDefined(IsUsingSdk) || hasPropertyOverride) { - builder.Append(" using_sdk:"); + builder.Append(" using_sdk: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsUsingSdk.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -474,23 +474,23 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Settings.Any() || hasPropertyOverride) { - builder.Append(" settings:"); + builder.Append(" settings: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Settings) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); continue; } - builder.AppendLine($" '{item.Value.ToString()}'"); + builder.AppendLine($"'{item.Value.ToString()}'"); } builder.AppendLine(" }"); } @@ -502,12 +502,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -528,13 +531,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteAnalysisDefinitionData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteAnalysisDefinitionData.Serialization.cs index 1403e3bc77bfc..cc95d85ea0f7c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteAnalysisDefinitionData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteAnalysisDefinitionData.Serialization.cs @@ -179,21 +179,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -201,21 +201,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -223,28 +223,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -253,21 +253,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); if (Optional.IsDefined(Description) || hasPropertyOverride) { - builder.Append(" description:"); + builder.Append(" description: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Description.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Description}'''"); } else { - builder.AppendLine($" '{Description}'"); + builder.AppendLine($"'{Description}'"); } } } @@ -277,12 +277,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -303,13 +306,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteData.Serialization.cs index 153b82527f2ce..f096acc467ff9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteData.Serialization.cs @@ -906,21 +906,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -928,14 +928,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); if (Optional.IsDefined(Location) || hasPropertyOverride) { - builder.Append(" location:"); + builder.Append(" location: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Location.ToString()}'"); + builder.AppendLine($"'{Location.ToString()}'"); } } @@ -944,17 +944,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Tags.Any() || hasPropertyOverride) { - builder.Append(" tags:"); + builder.Append(" tags: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Tags) { - builder.Append($" '{item.Key}':"); + builder.Append($" '{item.Key}': "); if (item.Value == null) { builder.Append("null"); @@ -962,12 +962,12 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } if (item.Value.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{item.Value}'''"); } else { - builder.AppendLine($" '{item.Value}'"); + builder.AppendLine($"'{item.Value}'"); } } builder.AppendLine(" }"); @@ -978,49 +978,49 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); if (Optional.IsDefined(Identity) || hasPropertyOverride) { - builder.Append(" identity:"); + builder.Append(" identity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, Identity, options, 2, false); + AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) { - builder.Append(" extendedLocation:"); + builder.Append(" extendedLocation: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false); + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -1028,28 +1028,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -1058,21 +1058,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (State.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{State}'''"); } else { - builder.AppendLine($" '{State}'"); + builder.AppendLine($"'{State}'"); } } } @@ -1082,14 +1082,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNames.Any() || hasPropertyOverride) { - builder.Append(" hostNames:"); + builder.Append(" hostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNames) { if (item == null) @@ -1115,21 +1115,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositorySiteName), out propertyOverride); if (Optional.IsDefined(RepositorySiteName) || hasPropertyOverride) { - builder.Append(" repositorySiteName:"); + builder.Append(" repositorySiteName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (RepositorySiteName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{RepositorySiteName}'''"); } else { - builder.AppendLine($" '{RepositorySiteName}'"); + builder.AppendLine($"'{RepositorySiteName}'"); } } } @@ -1137,29 +1137,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UsageState), out propertyOverride); if (Optional.IsDefined(UsageState) || hasPropertyOverride) { - builder.Append(" usageState:"); + builder.Append(" usageState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{UsageState.Value.ToSerialString()}'"); + builder.AppendLine($"'{UsageState.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) { - builder.Append(" enabled:"); + builder.Append(" enabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } @@ -1168,14 +1168,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (EnabledHostNames.Any() || hasPropertyOverride) { - builder.Append(" enabledHostNames:"); + builder.Append(" enabledHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in EnabledHostNames) { if (item == null) @@ -1201,14 +1201,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailabilityState), out propertyOverride); if (Optional.IsDefined(AvailabilityState) || hasPropertyOverride) { - builder.Append(" availabilityState:"); + builder.Append(" availabilityState: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AvailabilityState.Value.ToSerialString()}'"); + builder.AppendLine($"'{AvailabilityState.Value.ToSerialString()}'"); } } @@ -1217,17 +1217,17 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (HostNameSslStates.Any() || hasPropertyOverride) { - builder.Append(" hostNameSslStates:"); + builder.Append(" hostNameSslStates: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in HostNameSslStates) { - AppendChildObject(builder, item, options, 6, true); + AppendChildObject(builder, item, options, 6, true, " hostNameSslStates: "); } builder.AppendLine(" ]"); } @@ -1237,88 +1237,88 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppServicePlanId), out propertyOverride); if (Optional.IsDefined(AppServicePlanId) || hasPropertyOverride) { - builder.Append(" serverFarmId:"); + builder.Append(" serverFarmId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{AppServicePlanId.ToString()}'"); + builder.AppendLine($"'{AppServicePlanId.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReserved), out propertyOverride); if (Optional.IsDefined(IsReserved) || hasPropertyOverride) { - builder.Append(" reserved:"); + builder.Append(" reserved: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsReserved.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsXenon), out propertyOverride); if (Optional.IsDefined(IsXenon) || hasPropertyOverride) { - builder.Append(" isXenon:"); + builder.Append(" isXenon: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsXenon.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHyperV), out propertyOverride); if (Optional.IsDefined(IsHyperV) || hasPropertyOverride) { - builder.Append(" hyperV:"); + builder.Append(" hyperV: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHyperV.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedTimeUtc), out propertyOverride); if (Optional.IsDefined(LastModifiedTimeUtc) || hasPropertyOverride) { - builder.Append(" lastModifiedTimeUtc:"); + builder.Append(" lastModifiedTimeUtc: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(LastModifiedTimeUtc.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SiteConfig), out propertyOverride); if (Optional.IsDefined(SiteConfig) || hasPropertyOverride) { - builder.Append(" siteConfig:"); + builder.Append(" siteConfig: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SiteConfig, options, 4, false); + AppendChildObject(builder, SiteConfig, options, 4, false, " siteConfig: "); } } @@ -1327,14 +1327,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (TrafficManagerHostNames.Any() || hasPropertyOverride) { - builder.Append(" trafficManagerHostNames:"); + builder.Append(" trafficManagerHostNames: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" ["); + builder.AppendLine("["); foreach (var item in TrafficManagerHostNames) { if (item == null) @@ -1360,36 +1360,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsScmSiteAlsoStopped), out propertyOverride); if (Optional.IsDefined(IsScmSiteAlsoStopped) || hasPropertyOverride) { - builder.Append(" scmSiteAlsoStopped:"); + builder.Append(" scmSiteAlsoStopped: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsScmSiteAlsoStopped.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetSwapSlot), out propertyOverride); if (Optional.IsDefined(TargetSwapSlot) || hasPropertyOverride) { - builder.Append(" targetSwapSlot:"); + builder.Append(" targetSwapSlot: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (TargetSwapSlot.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{TargetSwapSlot}'''"); } else { - builder.AppendLine($" '{TargetSwapSlot}'"); + builder.AppendLine($"'{TargetSwapSlot}'"); } } } @@ -1397,79 +1397,79 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostingEnvironmentProfile), out propertyOverride); if (Optional.IsDefined(HostingEnvironmentProfile) || hasPropertyOverride) { - builder.Append(" hostingEnvironmentProfile:"); + builder.Append(" hostingEnvironmentProfile: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false); + AppendChildObject(builder, HostingEnvironmentProfile, options, 4, false, " hostingEnvironmentProfile: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsClientAffinityEnabled), out propertyOverride); if (Optional.IsDefined(IsClientAffinityEnabled) || hasPropertyOverride) { - builder.Append(" clientAffinityEnabled:"); + builder.Append(" clientAffinityEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsClientAffinityEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsClientCertEnabled), out propertyOverride); if (Optional.IsDefined(IsClientCertEnabled) || hasPropertyOverride) { - builder.Append(" clientCertEnabled:"); + builder.Append(" clientCertEnabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsClientCertEnabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCertMode), out propertyOverride); if (Optional.IsDefined(ClientCertMode) || hasPropertyOverride) { - builder.Append(" clientCertMode:"); + builder.Append(" clientCertMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ClientCertMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{ClientCertMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCertExclusionPaths), out propertyOverride); if (Optional.IsDefined(ClientCertExclusionPaths) || hasPropertyOverride) { - builder.Append(" clientCertExclusionPaths:"); + builder.Append(" clientCertExclusionPaths: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ClientCertExclusionPaths.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ClientCertExclusionPaths}'''"); } else { - builder.AppendLine($" '{ClientCertExclusionPaths}'"); + builder.AppendLine($"'{ClientCertExclusionPaths}'"); } } } @@ -1477,36 +1477,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHostNameDisabled), out propertyOverride); if (Optional.IsDefined(IsHostNameDisabled) || hasPropertyOverride) { - builder.Append(" hostNamesDisabled:"); + builder.Append(" hostNamesDisabled: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHostNameDisabled.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationId), out propertyOverride); if (Optional.IsDefined(CustomDomainVerificationId) || hasPropertyOverride) { - builder.Append(" customDomainVerificationId:"); + builder.Append(" customDomainVerificationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (CustomDomainVerificationId.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{CustomDomainVerificationId}'''"); } else { - builder.AppendLine($" '{CustomDomainVerificationId}'"); + builder.AppendLine($"'{CustomDomainVerificationId}'"); } } } @@ -1514,21 +1514,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutboundIPAddresses), out propertyOverride); if (Optional.IsDefined(OutboundIPAddresses) || hasPropertyOverride) { - builder.Append(" outboundIpAddresses:"); + builder.Append(" outboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (OutboundIPAddresses.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{OutboundIPAddresses}'''"); } else { - builder.AppendLine($" '{OutboundIPAddresses}'"); + builder.AppendLine($"'{OutboundIPAddresses}'"); } } } @@ -1536,21 +1536,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PossibleOutboundIPAddresses), out propertyOverride); if (Optional.IsDefined(PossibleOutboundIPAddresses) || hasPropertyOverride) { - builder.Append(" possibleOutboundIpAddresses:"); + builder.Append(" possibleOutboundIpAddresses: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (PossibleOutboundIPAddresses.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{PossibleOutboundIPAddresses}'''"); } else { - builder.AppendLine($" '{PossibleOutboundIPAddresses}'"); + builder.AppendLine($"'{PossibleOutboundIPAddresses}'"); } } } @@ -1558,92 +1558,92 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerSize), out propertyOverride); if (Optional.IsDefined(ContainerSize) || hasPropertyOverride) { - builder.Append(" containerSize:"); + builder.Append(" containerSize: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {ContainerSize.Value}"); + builder.AppendLine($"{ContainerSize.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DailyMemoryTimeQuota), out propertyOverride); if (Optional.IsDefined(DailyMemoryTimeQuota) || hasPropertyOverride) { - builder.Append(" dailyMemoryTimeQuota:"); + builder.Append(" dailyMemoryTimeQuota: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {DailyMemoryTimeQuota.Value}"); + builder.AppendLine($"{DailyMemoryTimeQuota.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuspendOn), out propertyOverride); if (Optional.IsDefined(SuspendOn) || hasPropertyOverride) { - builder.Append(" suspendedTill:"); + builder.Append(" suspendedTill: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var formattedDateTimeString = TypeFormatters.ToString(SuspendOn.Value, "o"); - builder.AppendLine($" '{formattedDateTimeString}'"); + builder.AppendLine($"'{formattedDateTimeString}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxNumberOfWorkers), out propertyOverride); if (Optional.IsDefined(MaxNumberOfWorkers) || hasPropertyOverride) { - builder.Append(" maxNumberOfWorkers:"); + builder.Append(" maxNumberOfWorkers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" {MaxNumberOfWorkers.Value}"); + builder.AppendLine($"{MaxNumberOfWorkers.Value}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CloningInfo), out propertyOverride); if (Optional.IsDefined(CloningInfo) || hasPropertyOverride) { - builder.Append(" cloningInfo:"); + builder.Append(" cloningInfo: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, CloningInfo, options, 4, false); + AppendChildObject(builder, CloningInfo, options, 4, false, " cloningInfo: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceGroup), out propertyOverride); if (Optional.IsDefined(ResourceGroup) || hasPropertyOverride) { - builder.Append(" resourceGroup:"); + builder.Append(" resourceGroup: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (ResourceGroup.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{ResourceGroup}'''"); } else { - builder.AppendLine($" '{ResourceGroup}'"); + builder.AppendLine($"'{ResourceGroup}'"); } } } @@ -1651,36 +1651,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefaultContainer), out propertyOverride); if (Optional.IsDefined(IsDefaultContainer) || hasPropertyOverride) { - builder.Append(" isDefaultContainer:"); + builder.Append(" isDefaultContainer: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsDefaultContainer.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultHostName), out propertyOverride); if (Optional.IsDefined(DefaultHostName) || hasPropertyOverride) { - builder.Append(" defaultHostName:"); + builder.Append(" defaultHostName: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (DefaultHostName.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{DefaultHostName}'''"); } else { - builder.AppendLine($" '{DefaultHostName}'"); + builder.AppendLine($"'{DefaultHostName}'"); } } } @@ -1688,93 +1688,93 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SlotSwapStatus), out propertyOverride); if (Optional.IsDefined(SlotSwapStatus) || hasPropertyOverride) { - builder.Append(" slotSwapStatus:"); + builder.Append(" slotSwapStatus: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - AppendChildObject(builder, SlotSwapStatus, options, 4, false); + AppendChildObject(builder, SlotSwapStatus, options, 4, false, " slotSwapStatus: "); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHttpsOnly), out propertyOverride); if (Optional.IsDefined(IsHttpsOnly) || hasPropertyOverride) { - builder.Append(" httpsOnly:"); + builder.Append(" httpsOnly: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsHttpsOnly.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RedundancyMode), out propertyOverride); if (Optional.IsDefined(RedundancyMode) || hasPropertyOverride) { - builder.Append(" redundancyMode:"); + builder.Append(" redundancyMode: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{RedundancyMode.Value.ToSerialString()}'"); + builder.AppendLine($"'{RedundancyMode.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InProgressOperationId), out propertyOverride); if (Optional.IsDefined(InProgressOperationId) || hasPropertyOverride) { - builder.Append(" inProgressOperationId:"); + builder.Append(" inProgressOperationId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{InProgressOperationId.Value.ToString()}'"); + builder.AppendLine($"'{InProgressOperationId.Value.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStorageAccountRequired), out propertyOverride); if (Optional.IsDefined(IsStorageAccountRequired) || hasPropertyOverride) { - builder.Append(" storageAccountRequired:"); + builder.Append(" storageAccountRequired: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { var boolValue = IsStorageAccountRequired.Value == true ? "true" : "false"; - builder.AppendLine($" {boolValue}"); + builder.AppendLine($"{boolValue}"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultReferenceIdentity), out propertyOverride); if (Optional.IsDefined(KeyVaultReferenceIdentity) || hasPropertyOverride) { - builder.Append(" keyVaultReferenceIdentity:"); + builder.Append(" keyVaultReferenceIdentity: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (KeyVaultReferenceIdentity.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{KeyVaultReferenceIdentity}'''"); } else { - builder.AppendLine($" '{KeyVaultReferenceIdentity}'"); + builder.AppendLine($"'{KeyVaultReferenceIdentity}'"); } } } @@ -1782,14 +1782,14 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkSubnetId), out propertyOverride); if (Optional.IsDefined(VirtualNetworkSubnetId) || hasPropertyOverride) { - builder.Append(" virtualNetworkSubnetId:"); + builder.Append(" virtualNetworkSubnetId: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{VirtualNetworkSubnetId.ToString()}'"); + builder.AppendLine($"'{VirtualNetworkSubnetId.ToString()}'"); } } @@ -1798,12 +1798,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -1824,13 +1827,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteInstanceStatusData.Serialization.cs b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteInstanceStatusData.Serialization.cs index 65f13358707c6..6e3dbfdddf5a4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteInstanceStatusData.Serialization.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/src/Generated/WebSiteInstanceStatusData.Serialization.cs @@ -267,21 +267,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" name:"); + builder.Append(" name: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Name.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($" '{Name}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -289,21 +289,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); if (Optional.IsDefined(Kind) || hasPropertyOverride) { - builder.Append(" kind:"); + builder.Append(" kind: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (Kind.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{Kind}'''"); } else { - builder.AppendLine($" '{Kind}'"); + builder.AppendLine($"'{Kind}'"); } } } @@ -311,28 +311,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" id:"); + builder.Append(" id: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{Id.ToString()}'"); + builder.AppendLine($"'{Id.ToString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (Optional.IsDefined(SystemData) || hasPropertyOverride) { - builder.Append(" systemData:"); + builder.Append(" systemData: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{SystemData.ToString()}'"); + builder.AppendLine($"'{SystemData.ToString()}'"); } } @@ -341,77 +341,77 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); if (Optional.IsDefined(State) || hasPropertyOverride) { - builder.Append(" state:"); + builder.Append(" state: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{State.Value.ToSerialString()}'"); + builder.AppendLine($"'{State.Value.ToSerialString()}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusUri), out propertyOverride); if (Optional.IsDefined(StatusUri) || hasPropertyOverride) { - builder.Append(" statusUrl:"); + builder.Append(" statusUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{StatusUri.AbsoluteUri}'"); + builder.AppendLine($"'{StatusUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DetectorUri), out propertyOverride); if (Optional.IsDefined(DetectorUri) || hasPropertyOverride) { - builder.Append(" detectorUrl:"); + builder.Append(" detectorUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{DetectorUri.AbsoluteUri}'"); + builder.AppendLine($"'{DetectorUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConsoleUri), out propertyOverride); if (Optional.IsDefined(ConsoleUri) || hasPropertyOverride) { - builder.Append(" consoleUrl:"); + builder.Append(" consoleUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($" '{ConsoleUri.AbsoluteUri}'"); + builder.AppendLine($"'{ConsoleUri.AbsoluteUri}'"); } } hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HealthCheckUrlString), out propertyOverride); if (Optional.IsDefined(HealthCheckUrlString) || hasPropertyOverride) { - builder.Append(" healthCheckUrl:"); + builder.Append(" healthCheckUrl: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { if (HealthCheckUrlString.Contains(Environment.NewLine)) { - builder.AppendLine(" '''"); + builder.AppendLine("'''"); builder.AppendLine($"{HealthCheckUrlString}'''"); } else { - builder.AppendLine($" '{HealthCheckUrlString}'"); + builder.AppendLine($"'{HealthCheckUrlString}'"); } } } @@ -421,18 +421,18 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) { if (Containers.Any() || hasPropertyOverride) { - builder.Append(" containers:"); + builder.Append(" containers: "); if (hasPropertyOverride) { - builder.AppendLine($" {propertyOverride}"); + builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine(" {"); + builder.AppendLine("{"); foreach (var item in Containers) { - builder.Append($" '{item.Key}':"); - AppendChildObject(builder, item.Value, options, 6, false); + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 6, false, " containers: "); } builder.AppendLine(" }"); } @@ -444,12 +444,15 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine) + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) { string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + BinaryData data = ModelReaderWriter.Write(childObject, options); string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - bool inMultilineString = false; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; @@ -470,13 +473,17 @@ private void AppendChildObject(StringBuilder stringBuilder, object childObject, } if (i == 0 && !indentFirstLine) { - stringBuilder.AppendLine($" {line}"); + stringBuilder.AppendLine($"{line}"); } else { stringBuilder.AppendLine($"{indent}{line}"); } } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)